********************************************************************************
* Title: Fast Track to Success? A Mixed Methods Evaluation of Condensed Course 
* Formats at Tennessee Community Colleges
* Authors: Matheny, Dell, Gluek, Baker, Bettinger, Monday, and Mesa
* Date: January 25, 2026
* Description: Replication Code 
********************************************************************************

* Set up the file
*****************

	* Prep Stata
	************
	
clear all
set matsize 10000
set maxvar 10000
set seed 102825

	* Tell Stata where to find the data
	***********************************

if c(username) == "kayle" { // see "Tips" below
gl dta "D:/Dropbox/Projects/Condensed Courses/Data/DTAalt/" // keep the end backslash
gl output "D:/Dropbox/Projects/Condensed Courses/AltOutput/" // keep the end backslash

// gl dta "C:/Users/ktm75/Dropbox/Projects/Condensed Courses/Data/DTAalt/"
// gl output "C:/Users/ktm75/Dropbox/Projects/Condensed Courses/AltOutput/"
}

// if c(username) == "INSERT_COMPUTER_USERNAME" { // see "Tips" below
// gl dta "INSERT_FILEPATH_FOR_DATA_FILES/" // keep the end backslash
// gl output "INSERT_FILEPATH_FOR_OUTPUT/" // keep the end backslash
// }

	* Tips
	******

* Common errors that you may encounter include: 
	* Not having relevant packages installed (e.g., ivreg2)
	* Not having enough RAM to run the models, especially the IV models
	* Not having a large enough data matrix (hence set matsize/maxvar above)

{ // Expand this menu for instructions on finding your computer's username
* How do I find the username on my computer? 
* --> On Windows (PC), type the Windows key + R. In the box that comes up, type
* --> netplwiz. Double click on your user information. Your username will be
* --> displayed there. On a Mac, open Finder and navigate to Go > Home. The name
* --> displayed at the top of the Finder window is your username. 
}

* Datasets
**********

	* Enrollment Level: 
* before_sample_restrictions.dta

	* Student Level: 
* cohort_based_outcomes_clean.dta
* hrs_by_term_cohort_analysis.dta
* cohort_analysis_covariates.dta
* fye_fys_courses.dta

* Table of Contents
*******************

	* Part I: Enrollment-Level Analyses: 
loc apptab2_panela_samprest = 1
loc table1_enrl_descriptives = 1
loc table2_enrl_selection = 1
loc table3_enrl_femodels = 1
loc table4_enrl_ivmodels = 1
loc table6_robus_bothfmts = 1
loc table7_robus_byschool = 1

	* Part II: Student-Level Analyses: 
loc apptab2_panelb_samprest = 1
loc table1_stud_descriptives = 1
loc table2_stud_selection = 1
loc table5_stud_femodels = 1
loc apptab4_fyedisagg = 1

********************************************************************************
***                   PART I: ENROLLMENT-LEVEL ANALYSES                      ***
********************************************************************************

********************************************************************************
** SAMPLE RESTRICTION & IMPACT ON SAMPLE SIZE - ENROLLMENT LEVEL
********************************************************************************

if `apptab2_panela_samprest' == 1 { 

********************************************************************
* The following code was used to generate Appendix Table 2, Panel A 
********************************************************************

cd "${output}"
log using "SampleRestrictions_Enrollment.smcl", replace

* Load in the Data
******************

use "${dta}before_sample_restrictions.dta", clear

* Counts before and after each sample restriction
*************************************************

* Full Sample - 4,207,550 obs
*****************************

	* assess the count
count
unique student_id
unique course_section_id

* Exclude Irregular Terms (i.e., summer, winter, continuing ed, and bootcamp)
*************************

	* exclude summer 
drop if term == "50" // 307,178 obs dropped 

	* exclude winter session  
drop if winter == 1 // 4,381 obs dropped 
drop winter 

	* exclude continuing education term
drop if ce_term == 1 // 190 obs dropped 
drop ce_term

	* exclude bootcamp terms
drop if bootcamp_term == 1 // 1,144 obs dropped 
drop bootcamp_term

	* assess the count
count
unique student_id
unique course_section_id

* Exclude Irregular Course Types (i.e., study abroad, clinicals, etc.) 
********************************

	* exclude study abroad 
drop if tncis == 1 // 7 obs dropped 
drop tncis

	* exclude irregular course types -- 54,859 obs dropped 
drop if instructional_method_desc == "Clinicals" | ///
	instructional_method_desc == "Independent Study" | ///
	instructional_method_desc == "Practicum" | ///
	instructional_method_desc == "Studnt tchng/field super/co-op" 	

	* assess the count
count
unique student_id
unique course_section_id

* Exclude eCampus Courses
*************************

drop if instructional_method_collapsed == "eCampus" // 100,193 obs dropped 

	* assess the count
count
unique student_id
unique course_section_id

* Exclude Dual Enrollment Students & Sections
*********************************************

	* exclude DE students
drop if de_student == 1 // 357,955 obs dropped 

	* exclude DE terms
drop if de_term == 1 // 1,408 obs dropped 
drop de_term 

	* assess the count
count
unique student_id
unique course_section_id

* Exclude by Irregular Course Lengths (i.e., too long or too short) 
*************************************

	* exclude courses < 6 weeks (change to rounded weeks because [college]'s 
	* 7-week terms were 5.8ish weeks in fall 2020 and spring 2021)
drop if term_length_weeks_rounded < 6 // 22,774 obs dropped 

	* exclude courses > 16 weeks in length 	
drop if term_length_weeks_rounded > 16 // 105 obs dropped 	

	* assess the count
count
unique student_id
unique course_section_id

* Exclude by Fuzzy Course Lengths (i.e., between condensed and regular-length) 
*********************************
 
drop if term_length_weeks_rounded>=9 & term_length_weeks_rounded<14

	* assess the count
count
unique student_id
unique course_section_id

* Exclude Learning Support Courses (because the grades are uninformative)
**********************************

drop if course_num_start < "10" & (subject_code == "MATH" | subject_code == ///
	"ENGL" | subject_code == "READ") // 216,627 obs deleted

	* assess the count
count
unique student_id
unique course_section_id

* Exclude Course Enrollments with Invalid Grades
************************************************

drop if final_grade == "AU" | final_grade == "NP" | final_grade == "NULL" | ///
		final_grade == "TNR" // 1,724 obs deleted

	* assess the count
count
unique student_id
unique course_section_id

* total final obs = 3,069,639 obs  

save "${dta}after_sample_restrictions.dta", replace 

log close 

}

*****************************************************************************
** BASE DESCRIPTIVES - ENROLLMENT LEVEL
*****************************************************************************

if `table1_enrl_descriptives' == 1 { 

****************************************************************************
* The following code was used to generate Enrollment-Level Counts in Table 1
****************************************************************************

cd "${output}"
log using "Descriptives_Enrollment.smcl", replace

* Load in the data
******************

use "${dta}after_sample_restrictions.dta", clear

* Identify Student's First Term
*******************************

unique student_id // 337,877
egen t1_term_code = min(term_code), by(student_id)
la var t1_term_code "Student's First Term" 

g course_enrollments = _n
la var course_enrollments "Course Enrollments"

*****************************************************************************
* Create Outcomes
*****************************************************************************

	* Clean up the final grade variable
g final_grade_clean = final_grade
replace final_grade_clean = "F" if final_grade == "F." // 1 change made
replace final_grade_clean = "Other Pass" if final_grade == "P" | ///
	final_grade == "S" // 50,064 changes made
replace final_grade_clean = "Other Fail" if final_grade == "N" | ///
	final_grade == "U" // 5,733 changes made
la var final_grade_clean "Final Grade"

	* Generate the ABC rate
g abc = final_grade == "A" | final_grade == "B" | final_grade == "C"
la var abc "Final Grade of A, B, or C" 

	* Generate the pass rate
g pass_rate = final_grade == "A" | final_grade == "B" | final_grade == "C" | ///
	final_grade == "D" | final_grade == "P" | final_grade == "S"
la var pass_rate "Final Grade is Passing"

	* Generate the withdrawal rate
g withdrawal = final_grade == "W"
la var withdrawal "Withdrawal" 

	* Generate the DFW rate
g dfw = final_grade == "D" | final_grade == "F" | final_grade == "F." | ///
	final_grade == "W" | final_grade == "N" | final_grade == "U" | ///
	final_grade == "FA"
la var dfw "Final Grade is a D, F, or Withdrawal" 

	* Generate the fail rate
g fail_rate = final_grade == "F" | final_grade == "F." |  final_grade == ///
	"N" | final_grade == "U" | final_grade == "FA"
la var fail_rate "Final Grade is Failing"

	* Generate the grade points
ta final_grade_clean, m
g grade_points = 0 if final_grade_clean == "F" | final_grade_clean == "FA" | ///
	final_grade_clean == "I" | final_grade_clean == "W" | final_grade_clean ///
	== "Other Fail"
replace grade_points = 1 if final_grade_clean == "D"
replace grade_points = 2 if final_grade_clean == "C"
replace grade_points = 2.5 if final_grade_clean == "Other Pass"
replace grade_points = 3 if final_grade_clean == "B"
replace grade_points = 4 if final_grade_clean == "A"
la var grade_points "Grade Points Earned" 

	* Generate the grade points *without pass/fail*
g grade_points_npf = 0 if final_grade_clean == "F" | ///
	final_grade_clean == "FA" | final_grade_clean == "I" | ///
	final_grade_clean == "W" 
replace grade_points_npf = 1 if final_grade_clean == "D"
replace grade_points_npf = 2 if final_grade_clean == "C"
replace grade_points_npf = 3 if final_grade_clean == "B"
replace grade_points_npf = 4 if final_grade_clean == "A"
la var grade_points_npf "Grade Points Earned (Without Pass Fail)"

* Generate a variable == 1 for students earning an A
g a_grade = final_grade_clean == "A"
la var a_grade "Final Grade of 'A'"

	* Defining term parts: 1st and 2nd accelerated session within a term 
	********************************************************************
	
gen month_start = month(start_date_stata)
la var month_start "Month of First Term Start" 

gen first_spring = 1 if accelerated_buckets==1 & (month_start == 1 | ///
	month_start == 2) // 1st term spring
la var first_spring "First Term Spring"
gen second_spring = 1 if accelerated_buckets==1 & (month_start == 3 | ///
	month_start == 4) // 2nd term spring
la var second_spring "Second Term Spring"

gen first_fall = 1 if accelerated_buckets==1 & (month_start == 7 | ///
	month_start == 8 | month_start == 9) // 1st term fall
la var first_fall "First Term Fall"
gen second_fall = 1 if accelerated_buckets==1 & (month_start == 10 | ///
	month_start == 11) // 2nd term fall
la var second_fall "Second Term Fall"

gen first_term = 1 if accelerated_buckets==1 & (first_fall==1 | ///
	first_spring==1) // first term 
la var first_term "First Term"
gen second_term = 1 if accelerated_buckets==1 & (second_fall==1 | ///
	second_spring==1) // second term 
la var second_term "Second Term"

gen full_fall = 1 if accelerated_buckets==3 & month_start>6 // full fall
la var full_fall "Full Fall"
gen full_spring = 1 if accelerated_buckets==3 & month_start<6 // full spring
la var full_spring "Full Spring"

	* Specifying the session
	************************
	
gen session_categorical = .
replace session_categorical = 0 if full_fall==1 | full_spring==1 
replace session_categorical = 1 if first_term == 1 
replace session_categorical = 2 if second_term == 1 
la var session_categorical "Session" 

label define lab_session_cat 0 "15-week term", add
label define lab_session_cat 1 "1st 7-week session", add
label define lab_session_cat 2 "2nd 7-week session", add
label values session_categorical lab_session_cat

*****************************************************************************
* Create Fixed Effects
*****************************************************************************

	* Create subject code FE (numeric version of this string variable)
egen fe_subject_code = group(subject_code)
la var fe_subject_code "Subject FE"

	* Create the variable for the modality FE
replace instructional_method_collapsed = "Other Method" if ///
	instructional_method_collapsed == "" // 5 changes made
encode instructional_method_collapsed, gen(modality_fe)
la var modality_fe "Modality FE" 

	* Create twodig_cip by term_code FE
tostring twodig_cip, gen(twodig_cip_str)
g twodigcip_byterm = term_code_str + " " + twodig_cip_str
egen fe_twodigcip_byterm = group(twodigcip_byterm)
la var fe_twodigcip_byterm "CIP by Term FE"

	* Course (subject + course code, e.g. ENG 1000) by term_code FE
tostring course_fe, g(course_fe_string)
g course_fe_byterm = term_code_str + " " + course_fe_string
egen fe_subjcdcoursenum_byterm = group(course_fe_byterm)
la var fe_subjcdcoursenum_byterm "Course by Term FE"

********************************************************************************
* Accelerated exposure/dosage by student  
********************************************************************************

gen course_num = 1 
la var course_num "N"

gen course_acc = 0
replace course_acc=1 if accelerated_buckets==1
gen course_trad = 1 if accelerated_buckets==3

la var course_acc "Condensed Course Indicator"
la var course_trad "Traditional-Length Course Indicator"

* by student (student_id) in full data set 
bysort student_id: egen stu_acc_binary = max(course_acc) 
	* has student taken any accelerated?
bysort student_id: egen stu_acc_num = sum(course_acc) 
	* how many accelerated has student taken 
bysort student_id: egen stu_tot_num = sum(course_num) 
	* how many courses has student taken
g stu_pct_acc = stu_acc_num/stu_tot_num 
	* share of credits from accelerated

la var stu_tot_num "Total Number of Courses Taken"
la var stu_acc_binary "Ever Took a Condensed Course"
la var stu_acc_num "Number of Condensed Courses Taken"
la var stu_pct_acc "Percent of Courses Condensed"
	
* by student within a given semester 
bysort student_id term_code: egen stu_acc_binary_term = max(course_acc) 
	* has student taken any accelerated?
bysort student_id term_code: egen stu_acc_num_term = sum(course_acc) 
	* how many accelerated has student taken?
bysort student_id term_code: egen stu_tot_num_term = sum(course_num)	
	* how many classes is student taking 
gen stu_pct_acc_term = stu_acc_num_term/stu_tot_num_term 
	* share of credits from accelerated

la var stu_acc_binary_term "Took Any Condensed Course That Term"
la var stu_acc_num_term "Number of Condensed Courses Taken That Term"
la var stu_pct_acc_term "Percent of Courses Condensed That Term"	

********************************************************************************
* Are students actually deciding between accelerated vs traditional?  
********************************************************************************

* Identify courses being offered in both "terms" (meaning accelerated and 
* traditional)
	* doing this by looking at if a course has full or accelerated offerings 
	* in that same term 
	* then create the both variable by saying if both are true 

* By inst, term, course: 
* Is course offered in traditional & accelerated formats? (ignores modality)
 
gen accelerated_term = 0 
replace accelerated_term = 1 if accelerated_buckets==1 
la var accelerated_term "Condensed Course"

drop full_term
gen full_term = 0 
replace full_term = 1 if accelerated_buckets==3 
la var full_term "Traditional-Length Course"

bysort institution term_code course_fe: ///
	egen offered_full_term = max(full_term) 
bysort institution term_code course_fe: ///
	egen offered_acc_term = max(accelerated_term) 
bysort institution term_code course_fe: ///
	gen offered_both_term = 1 if offered_full_term==1 & offered_acc_term==1

la var offered_full_term "Course is Offered in Full Term" 
la var offered_acc_term "Course is Offered in Condensed Term" 
la var offered_both_term "Course is Offered in Both Full and Condensed Terms" 

********************************************************************************					
* Are courses offered in different terms and different modalities?
	* Does a given course have accelerated offerings in each modality? 
	* Does a given course have fullterm offerings in each modality?
	* Are accelerated and full are both offered in the same modality?
********************************************************************************					

* by inst, term, course: if course is offered as accelerated by modality
bysort institution term_code course_fe: ///
	egen offered_acc_online = max(accelerated_term) if modality_fe==1  
bysort institution term_code course_fe: ///
	egen offered_acc_conv = max(accelerated_term) if modality_fe==2  
bysort institution term_code course_fe: ///
	egen offered_acc_hybrid = max(accelerated_term) if modality_fe==3  
bysort institution term_code course_fe: ///
	egen offered_acc_other = max(accelerated_term) if modality_fe==4  

* by inst, term, course: if course is offered as full term by modality
bysort institution term_code course_fe: ///
	egen offered_full_online = max(full_term) if modality_fe==1  
bysort institution term_code course_fe: ///
	egen offered_full_conv = max(full_term) if modality_fe==2  
bysort institution term_code course_fe: ///
	egen offered_full_hybrid = max(full_term) if modality_fe==3  
bysort institution term_code course_fe: ///
	egen offered_full_other = max(full_term) if modality_fe==4  

* by inst, term, course: 
* if course is offered as both accelerated and full term by modality 
bysort institution term_code course_fe: ///
	g offered_both_online = 1 if offered_full_online==1 & offered_acc_online==1
bysort institution term_code course_fe: ///
	g offered_both_conv = 1 if offered_full_conv==1 & offered_acc_conv==1
bysort institution term_code course_fe: ///
	g offered_both_hybrid = 1 if offered_full_hybrid==1 & offered_acc_hybrid==1
bysort institution term_code course_fe: ///
	g offered_both_other = 1 if offered_full_other==1 & offered_acc_other==1

* by inst, term, & course: instances of same modality & both term types
gen offered_both_bymodality = 0 
bysort institution term_code course_fe: ///
	replace offered_both_bymodality = 1 if ///
						offered_both_online == 1 | ///
						offered_both_conv == 1 | ///
						offered_both_hybrid == 1 | ///
						offered_both_other == 1 
	
********************************************************************************
* Same as above but looking within campus
* (relevant only for hybrid & conventional)
********************************************************************************					

* for accelerated by modality  
bysort institution term_code course_fe: ///
	egen offered_acc_online_campus = max(accelerated_term) if modality_fe==1  
bysort institution term_code course_fe campus_code: ///
	egen offered_acc_conv_campus = max(accelerated_term) if modality_fe==2  
bysort institution term_code course_fe campus_code: ///
	egen offered_acc_hybrid_campus = max(accelerated_term) if modality_fe==3  
bysort institution term_code course_fe: ///
	egen offered_acc_other_campus = max(accelerated_term) if modality_fe==4  

* for full term by modality
bysort institution term_code course_fe: ///
	egen offered_full_online_campus = max(full_term) if modality_fe==1  
bysort institution term_code course_fe campus_code: ///
	egen offered_full_conv_campus = max(full_term) if modality_fe==2  
bysort institution term_code course_fe campus_code: ///
	egen offered_full_hybrid_campus = max(full_term) if modality_fe==3  
bysort institution term_code course_fe: ///
	egen offered_full_other_campus = max(full_term) if modality_fe==4  

* both accelerated and full term by modality 
bysort institution term_code course_fe: ///
	g offered_both_online_campus = 1 if offered_full_online_campus==1 & ///
	offered_acc_online_campus==1
bysort institution term_code course_fe campus_code: ///
	g offered_both_conv_campus = 1 if offered_full_conv_campus==1 & ///
	offered_acc_conv_campus==1
bysort institution term_code course_fe campus_code: ///
	g offered_both_hybrid_campus = 1 if offered_full_hybrid_campus==1 & ///
	offered_acc_hybrid_campus==1
bysort institution term_code course_fe: ///
	g offered_both_other_campus = 1 if offered_full_other_campus==1 & ///
	offered_acc_other_campus==1

* by inst, term, & course: 
* are there any instances of same modality & both term types

gen offered_both_campus = 0 
bysort institution term_code course_fe campus_code: ///
	replace offered_both_campus = 1 if ///
						offered_both_online_campus == 1 | ///
						offered_both_conv_campus == 1 | ///
						offered_both_hybrid_campus == 1 | ///
						offered_both_other_campus == 1 
						
********************************************************************************
* Additional Variables
********************************************************************************					
					
	* Learning support placement indicators
	***************************************

label define ls 0 "No", add
label define ls 1 "Yes", add
foreach var of varlist ls_* {
	label values `var' ls
}

	* Composite learning support variable
	*************************************

egen ls_number = rowtotal(ls_math_required ls_reading_required ///
	ls_writing_required)
g any_ls_required = ls_number > 0
g ls_required = "No LS Required"
replace ls_required = "Math Only" if ls_math_required == 1 & ///
	ls_reading_required == 0 & ls_writing_required == 0
replace ls_required = "Reading Only" if ls_math_required == 0 & ///
	ls_reading_required == 1 & ls_writing_required == 0
replace ls_required = "Writing Only" if ls_math_required == 0 & ///
	ls_reading_required == 0 & ls_writing_required == 1
replace ls_required = "Math and Reading" if ls_math_required == 1 & ///
	ls_reading_required == 1 & ls_writing_required == 0
replace ls_required = "Math and Writing" if ls_math_required == 1 & ///
	ls_reading_required == 0 & ls_writing_required == 1
replace ls_required = "Reading and Writing" if ls_math_required == 0 & ///
	ls_reading_required == 1 & ls_writing_required == 1
replace ls_required = "Math, Reading, and Writing" if ls_math_required == 1 ///
	& ls_reading_required == 1 & ls_writing_required == 1
la var ls_number "Number of Required Learning Support Courses (0-3)"
la var ls_required "Required Learning Support Courses"
la var any_ls_required "Any Learning Support Courses Required"

	* Binary modalities 
	*******************

g modality_online_remote = 0
replace modality_online_remote = 1 if modality_fe == 1
g modality_conventional = 0
replace modality_conventional = 1 if modality_fe == 2
g modality_hybrid = 0
replace modality_hybrid = 1 if modality_fe == 3
g modality_other = 0
replace modality_other = 1 if modality_fe == 4
la var modality_online_remote "Remote Modality"
la var modality_conventional "In-Person Modality"
la var modality_hybrid "Hybrid Modality"
la var modality_other "Other Modality"

	* Other Race
	************

	* Examining distributions by enrollment and student
foreach var in asian ak_native black hisp white race_unknown am_ind multi ///
	nh_pi { 
sum `var' // Black, Hispanic, and White each constitute 5%+
tab `var' if student==1 // Black, Hispanic, White, Asian, and Multi have 1000+
}

	* Version 1) Collapsing all groups under 5%
gen race_other = 0
replace race_other=1 if asian==1 | ak_native==1 | race_unknown==1 | ///
						am_ind==1 | multi==1 | nh_pi == 1  
la var race_other "Other Race" 

	* Version 2) Collapsing all groups under 1000 students 
gen race_oth_under1000 = 0
replace race_oth_under1000 = 1 if ak_native==1 | race_unknown==1 | ///
						am_ind==1 | nh_pi == 1  
la var race_oth_under1000 "Other Race"

	* Adjusting CIP Code
	********************

replace twodig_cip = 999 if twodig_cip==.								

	* Save the Dataset
	******************

save "${dta}analytic_dataset.dta", replace

* Generate Descriptives
***********************

	* Run summary stats
	*******************

asdoc tabstat age_25plus pell_recipient female asian black hisp multi ///
	race_oth_under1000 white full_time ft_fresh ls_number ls_math_required ///
	ls_reading_required ls_writing_required hs_gpa_clean ///
	hs_gpa_models_missing, ///
		stat(mean sd count) dec(2) c(statistics) label ///
		save(table1_descriptives_enrl.doc) replace

log close

}

*****************************************************************************
** SELECTION - ENROLLMENT LEVEL
*****************************************************************************

if `table2_enrl_selection' == 1 { 

******************************************************************************
* The following code was used to generate Enrollment-Level Analyses in Table 2 
******************************************************************************

cd "${output}"
log using "Selection_Enrollment.smcl", replace

* Load in the data
******************

use "${dta}analytic_dataset.dta", clear
cd "${output}"

* Run selection analyses
************************

foreach var of varlist age_25plus pell_recipient female asian black hisp ///
	multi race_oth_under1000 white full_time ft_fresh ///
	ls_number ls_math_required ls_reading_required ls_writing_required ///
	hs_gpa_clean hs_gpa_models_missing {

	* Identify means by control and treatment
bysort accelerated_term: su `var'
	
	* Calculating the naive OLS
reg `var' accelerated_term, robust 
outreg2 using control_`var'.xls, excel replace ctitle(OLS) ///
	keep(accelerated_term) dec(3) alpha(0.001, 0.01, 0.05)
	
	* Running the primary specification
	***********************************

* institution, term-year, course_fe, & modality	FEs
areg `var' accelerated_term i.institution i.term_code i.modality_fe, ///
	absorb(course_fe) vce(robust)
outreg2 using control_`var'.xls, append ctitle(FE) ///
	keep(accelerated_term) ///
	addtext(Institution FE, YES, Term by Year FE, YES, Course Subj & Num FE, ///
	YES, Modality FE, YES) ///
	dec(3) alpha(0.001, 0.01, 0.05)		

} 	

log close

}

*****************************************************************************
** MAIN ANALYSIS - ENROLLMENT-LEVEL FIXED EFFECTS
*****************************************************************************

if `table3_enrl_femodels' == 1 {

*************************************************
* The following code was used to generate Table 3
*************************************************

cd "${output}"
log using "FixedEffects_Enrollment.smcl", replace

* Load in the data
******************

use "${dta}analytic_dataset.dta", clear

* Run FE outcomes analyses
**************************

	* Define covariate local
local control_vars age_25plus pell_recipient female asian black hisp ///
	multi race_oth_under1000 full_time ft_fresh ///
	ls_math_required ls_reading_required ls_writing_required ///
	hs_gpa_models hs_gpa_models_missing

	* Identify SDs for continuous variables
bysort accelerated_term: su grade_points grade_points_npf

	* Run model loop
foreach var of varlist pass_rate fail_rate withdrawal grade_points ///
	grade_points_npf {

* naive OLS	model		
reg `var' accelerated_term, robust 
outreg2 using outcome_`var'.xls, excel replace ctitle(OLS) ///
	keep(accelerated_term) dec(3) alpha(0.001, 0.01, 0.05)

* naive OLS w/controls 
reg `var' accelerated_term `control_vars', robust 
outreg2 using outcome_`var'.xls, excel append ctitle(OLS) ///
	keep(accelerated_term) dec(3) addtext(Control Variables, YES) ///
	alpha(0.001, 0.01, 0.05)

	* Primary model specifications
	******************************

* FEs: institution & term-year FE
areg `var' accelerated_term `control_vars' i.term_code, ///
	absorb(institution) vce(robust)
outreg2 using outcome_`var'.xls, append ctitle(FE) ///
	keep(accelerated_term) ///
	addtext(Control Variables, YES, Institution FE, YES, Term by Year FE, ///
	YES) ///
	dec(3) alpha(0.001, 0.01, 0.05) 

* FEs: institution, term-year, & twodig cip 			
areg `var' accelerated_term `control_vars' i.institution i.term_code, ///
	absorb(twodig_cip) vce(robust)
outreg2 using outcome_`var'.xls, append ctitle(FE) keep(accelerated_term) ///
	addtext(Control Variables, YES, Institution FE, YES, Term by Year FE, ///
	YES, CIP Code FE, YES) ///
	dec(3) alpha(0.001, 0.01, 0.05) 

* FEs: institution, term-year, twodig cip, & modality 			
areg `var' accelerated_term `control_vars' i.institution i.term_code ///
	i.modality_fe, absorb(twodig_cip) vce(robust)
outreg2 using outcome_`var'.xls, append ctitle(FE) keep(accelerated_term) ///
	addtext(Control Variables, YES, Institution FE, YES, Term by Year FE, ///
	YES, CIP Code FE, YES, Modality FE, YES) ///
	dec(3) alpha(0.001, 0.01, 0.05) 	
		
* FEs: institution, term-year, course_fe, & modality 			
areg `var' accelerated_term `control_vars' i.institution i.term_code ///
	i.modality_fe, absorb(course_fe) vce(robust)
outreg2 using outcome_`var'.xls, append ctitle(FE) keep(accelerated_term) ///
	addtext(Control Variables, YES, Institution FE, YES, Term by Year FE, ///
	YES, Course Subj & Num FE, YES, Modality FE, YES) ///
	dec(3) alpha(0.001, 0.01, 0.05)	

* FEs: student (student_id)		
areg `var' accelerated_term `control_vars', absorb(student_id) vce(robust)
outreg2 using outcome_`var'.xls, append ctitle(FE) keep(accelerated_term) ///
	addtext(Control Variables, YES, Student FE, YES) ///
	dec(3) alpha(0.001, 0.01, 0.05)	

* FEs: student and modality
areg `var' accelerated_term `control_vars' i.modality_fe, ///
	absorb(student_id) vce(robust)
outreg2 using outcome_`var'.xls, append ctitle(FE) keep(accelerated_term) ///
	addtext(Control Variables, YES, Modality FE, YES, Student FE, YES) ///
	dec(3) alpha(0.001, 0.01, 0.05)	
	
* FEs: student, institution, term-year, and modality
areg `var' accelerated_term `control_vars' i.institution i.term_code ///
	i.modality_fe, absorb(student_id) vce(robust)
outreg2 using outcome_`var'.xls, append ctitle(FE) keep(accelerated_term) ///
	addtext(Control Variables, YES, Institution FE, YES, Modality FE, YES, ///
	Term by Year FE, YES, Student FE, YES) ///
	dec(3) alpha(0.001, 0.01, 0.05)	
	
* FEs: student, institution, term-year, modality, and twodig cip
areg `var' accelerated_term `control_vars' i.institution i.term_code ///
	i.modality_fe i.twodig_cip, absorb(student_id) vce(robust)
outreg2 using outcome_`var'.xls, append ctitle(FE) keep(accelerated_term) ///
	addtext(Control Variables, YES, Institution FE, YES, Modality FE, YES, ///
	Term by Year FE, YES, Student FE, YES, CIP Code FE, YES) ///
	dec(3) alpha(0.001, 0.01, 0.05)	
	
} 	

log close

} 

*****************************************************************************
** MAIN ANALYSIS - IV SPECIFICATIONS
*****************************************************************************

if `table4_enrl_ivmodels' == 1 {

*************************************************
* The following code was used to generate Table 4
*************************************************

cd "${output}"
log using "IV_Enrollment.smcl", replace

* Load in the dataset
*********************

use "${dta}analytic_dataset.dta", clear

* Enrollment-Level Instrumental Variables
*****************************************

	* Generate instruments
	**********************

	* Collapse the dataset to sum course enrollments 
	* by inst, term, course, and length
collapse (sum) course_enrollments, ///
	by(institution term_code course_fe course_acc)
format course_enrollments %15.0f

	* Generate the number of total course enrollments by term, inst, and course
bysort institution term_code course_fe (course_acc): ///
	egen tot_students = total(course_enrollments), m
format tot_students %15.0f

	* Generate the percent of course enrollments in 15- and 7-week formats
g pct_enrollments = course_enrollments / tot_students

	* Reshape the dataset so each row is unique by term, inst, and course
reshape wide course_enrollments tot_students pct_enrollments, ///
	i(institution term_code course_fe) j(course_acc)

	* Generate a variable with the total number of course enrollments by course	
g tot_students = tot_students0
replace tot_students = tot_students1 if tot_students == .
drop tot_students0 tot_students1

	* Rename the variables so it's clear which is 15-week and which is 7-week
rename (*0 *1) (*_15wk *_7wk)
format course_enrollments_15wk %15.0f
format course_enrollments_7wk %15.0f
format tot_students %15.0f

	* Replace missing values with 0 (as appropriate)
		* these are cases where there were no 15-week or 7-week course 
		* enrollments in a particular inst, term, and course

foreach var of varlist *15wk {
replace `var' = 0 if pct_enrollments_7wk >= .9999 & pct_enrollments_7wk != .
}

foreach var of varlist *7wk {
replace `var' = 0 if pct_enrollments_15wk >= .9999 & pct_enrollments_15wk != . 
}

	* Keep only the variables we need and save the dataset
drop *15wk course_enrollments_7wk
tempfile iv_course_enrollments
save `iv_course_enrollments'

	* Save a version of the dataset where the variable values are from the last 
	* YEAR a course was offered in the same semester so we can easily merge with 
	* the main IV dataset
g year = real(substr(string(term_code, "%6.0f"), 1, 4))
g term = real(substr(string(term_code, "%6.0f"), 5, 2))
foreach var of varlist pct_enrollments_7wk tot_students {
	bysort institution course_fe term (year): g `var'_last_year = `var'[_n-1]
}

drop pct_enrollments_7wk tot_students term year
tempfile iv_course_enrollments_last_year
save `iv_course_enrollments_last_year'

	* Save a version of the dataset where the variable values are from the last 
	* TERM a course was offered so we can easily merge with the main IV dataset
use `iv_course_enrollments', clear
foreach var of varlist pct_enrollments_7wk tot_students {
	bysort institution course_fe (term_code): g `var'_last_term = `var'[_n-1]
}

drop pct_enrollments_7wk tot_students
tempfile iv_course_enrollments_last_term
save `iv_course_enrollments_last_term'

	* Merge all the instrument datasets together 
use `iv_course_enrollments', clear
merge 1:1 institution course_fe term_code using ///
	`iv_course_enrollments_last_year', gen(merge_year) keep(master match)
merge 1:1 institution course_fe term_code using ///
	`iv_course_enrollments_last_term', gen(merge_term) keep(master match)
tempfile iv_final_course_enrollments
save `iv_final_course_enrollments'

	* Merge analytic dataset with instruments
use "${dta}analytic_dataset.dta", clear
merge m:1 term_code institution course_fe using ///
	`iv_final_course_enrollments', keep(master match) gen(merge_final)

	* Run IV outcomes analyses
	**************************

	* Generate versions of the tot variables that are ln() and in 1000s
foreach var of varlist tot_students_last_year tot_students_last_term {
g ln_`var' = ln(`var')
g in1000s_`var' = `var' / 1000
}

	* Define covariate local
local control_vars age_25plus pell_recipient female asian black hisp ///
	multi race_oth_under1000 full_time ft_fresh ///
	ls_math_required ls_reading_required ls_writing_required ///
	hs_gpa_models hs_gpa_models_missing
	
su pct* tot*

	* Last Term as IV, Enrollment as LN
	***********************************

foreach dv of varlist pass_rate fail_rate withdrawal grade_points {
	
ivreg2 `dv' (accelerated_term = pct_enrollments_7wk_last_term ///
	ln_tot_students_last_term) ///
	i.institution i.term_code i.modality_fe i.fe_subject_code ///
	`control_vars', first savefirst

outreg2 using "iv_course_enrollments_`dv'.xls", replace ///
	dec(3) alpha(0.001, 0.01, 0.05) ///
	addtext(IV Stage, Second, IV is Last..., Term, Total Students..., ln) ///
	keep(accelerated_term)
est restore _ivreg2_accelerated_term

outreg2 using "iv_course_enrollments_`dv'.xls", ///
	append dec(3) alpha(0.001, 0.01, 0.05) ///
	addtext(IV Stage, First, IV is Last..., Term, Total Students..., ln) ///
	keep(pct_enrollments_7wk_last_term ln_tot_students_last_term)
}

	* Last Term as IV, Enrollment as 1000s
	**************************************

foreach dv of varlist pass_rate fail_rate withdrawal grade_points {

ivreg2 `dv' (accelerated_term = pct_enrollments_7wk_last_term ///
	in1000s_tot_students_last_term) ///
	i.institution i.term_code i.modality_fe i.fe_subject_code ///
	`control_vars', first savefirst

outreg2 using "iv_course_enrollments_`dv'.xls", append ///
	dec(3) alpha(0.001, 0.01, 0.05) ///
	addtext(IV Stage, Second, IV is Last..., Term, Total Students..., ///
	in1000s) keep(accelerated_term)
est restore _ivreg2_accelerated_term

outreg2 using "iv_course_enrollments_`dv'.xls", append ///
	dec(3) alpha(0.001, 0.01, 0.05) ///
	addtext(IV Stage, First, IV is Last..., Term, Total Students..., ///
	in1000s) keep(pct_enrollments_7wk_last_term ln_tot_students_last_term)
}

	* Last Year as IV, Enrollment as LN
	***********************************

foreach dv of varlist pass_rate fail_rate withdrawal grade_points {

ivreg2 `dv' (accelerated_term = pct_enrollments_7wk_last_year ///
	ln_tot_students_last_year) i.institution i.term_code i.modality_fe ///
	i.fe_subject_code `control_vars', first savefirst

outreg2 using "iv_course_enrollments_`dv'.xls", append ///
	dec(3) alpha(0.001, 0.01, 0.05) ///
	addtext(IV Stage, Second, IV is Last..., Year, Total Students..., ln) ///
	keep(accelerated_term)
est restore _ivreg2_accelerated_term
outreg2 using "iv_course_enrollments_`dv'.xls", append ///
	dec(3) alpha(0.001, 0.01, 0.05) ///
	addtext(IV Stage, First, IV is Last..., Year, Total Students..., ln) ///
	keep(pct_enrollments_7wk_last_term ln_tot_students_last_term)
}

	* Last Year as IV, Enrollment as 1000s
	**************************************

foreach dv of varlist pass_rate fail_rate withdrawal grade_points {

ivreg2 `dv' (accelerated_term = pct_enrollments_7wk_last_year ///
	in1000s_tot_students_last_year) ///
	i.institution i.term_code i.modality_fe i.fe_subject_code ///
	`control_vars', first savefirst

outreg2 using "iv_course_enrollments_`dv'.xls", append ///
	dec(3) alpha(0.001, 0.01, 0.05) ///
	addtext(IV Stage, Second, IV is Last..., Year, Total Students..., ///
	in1000s) keep(accelerated_term)
est restore _ivreg2_accelerated_term

outreg2 using "iv_course_enrollments_`dv'.xls", append ///
	dec(3) alpha(0.001, 0.01, 0.05) ///
	addtext(IV Stage, First, IV is Last..., Year, Total Students..., ///
	in1000s) ///
	keep(pct_enrollments_7wk_last_term ln_tot_students_last_term)
}

* Section-Level Instrumental Variables
**************************************

	* Load in the data
	******************

use "${dta}analytic_dataset.dta", clear

	* Generate instruments
	**********************

	* Collapse the dataset to sum course sections 
	* by inst, term, course, and length
bysort institution term_code course_crn course_acc: keep if _n == 1
rename course_enrollments course_sections
collapse (sum) course_sections, by(institution term_code course_fe course_acc)

	* Generate the number of total course sections by inst, term, and course
bysort institution term_code course_fe (course_acc): ///
	egen tot_sections = total(course_sections), m

	* Generate the percent of course sections in 15- and 7-week formats
g pct_sections = course_sections / tot_sections

	* Reshape the dataset so each row is unique by inst, term, and course
reshape wide course_sections tot_sections pct_sections, ///
	i(institution term_code course_fe) j(course_acc)

	* Generate a variable with the total number of course sections by course	
g tot_sections = tot_sections0
replace tot_sections = tot_sections1 if tot_sections == .
drop tot_sections0 tot_sections1

	* Rename the variables so it's clear which is 15-week and which is 7-week
rename (*0 *1) (*_15wk *_7wk)

	* Replace missing values with 0 (as appropriate) 
		* these are cases where there were no 15-week or 7-week course sections 
		* in a particular term, inst, and course

foreach var of varlist *15wk {
	replace `var' = 0 if course_sections_7wk == tot_sections
	replace `var' = 0 if course_sections_7wk >= .9999 & course_sections_7wk != .
}

foreach var of varlist *7wk {
	replace `var' = 0 if course_sections_15wk == tot_sections
	replace `var' = 0 if course_sections_15wk >= .9999 & ///
		course_sections_15wk != . 
}

	* Keep only the variables we need and save the dataset
drop *15wk course_sections_7wk
tempfile iv_course_sections
save `iv_course_sections'

	* Save a version of the dataset where the variable values are from the last 
	* YEAR a course was offered in the same semester so we can easily merge with 
	* the main IV dataset

g year = real(substr(string(term_code, "%6.0f"), 1, 4))
g term = real(substr(string(term_code, "%6.0f"), 5, 2))

foreach var of varlist pct_sections_7wk tot_sections {
	bysort institution course_fe term (year): ///
	g `var'_last_year = `var'[_n-1]
}

drop pct_sections_7wk tot_sections term year
tempfile iv_course_sections_last_year
save `iv_course_sections_last_year'

	* Save a version of the dataset where the variable values are from the last 
	* TERM a course was offered so we can easily merge with the main IV dataset

use `iv_course_sections', clear

foreach var of varlist pct_sections_7wk tot_sections {
	bysort institution course_fe (term_code): ///
	g `var'_last_term = `var'[_n-1]
}

drop pct_sections_7wk tot_sections
tempfile iv_course_sections_last_term
save `iv_course_sections_last_term'

	* Merge all the instrument datasets together before merging with the 
	* analytic dataset

use `iv_course_sections', clear

merge 1:1 institution course_fe term_code using ///
	`iv_course_sections_last_year', gen(merge_year) keep(master match)
	
merge 1:1 institution course_fe term_code using ///
	`iv_course_sections_last_term', gen(merge_term) keep(master match)
	
tempfile iv_final_course_sections
save `iv_final_course_sections'

	* Merge analytic dataset with instruments
	
use "${dta}analytic_dataset.dta", clear
merge m:1 term_code institution course_fe using ///
	`iv_final_course_sections', keep(master match) gen(merge_final)

	* Generate a version of the tot variables that is ln()
	
foreach var of varlist tot_sections_last_year tot_sections_last_term {
	g ln_`var' = ln(`var')
}
		
	* Run IV Models by Section
	**************************

	* Define covariate local
local control_vars age_25plus pell_recipient female asian black hisp ///
	multi race_oth_under1000 full_time ft_fresh ///
	ls_math_required ls_reading_required ls_writing_required ///
	hs_gpa_models hs_gpa_models_missing

su pct* tot*

	* Percent of Sections Offered Last Term as IV
	*********************************************

foreach dv of varlist pass_rate fail_rate withdrawal grade_points {

ivreg2 `dv' (accelerated_term = pct_sections_7wk_last_term ///
	ln_tot_sections_last_term) ///
	i.institution i.term_code i.modality_fe i.fe_subject_code ///
	`control_vars', first savefirst

outreg2 using "iv_course_sections_`dv'.xls", replace ///
	dec(3) alpha(0.001, 0.01, 0.05) ///
	addtext(IV Stage, Second, IV is Last..., Term, Total Students..., ln) ///
	keep(accelerated_term)
est restore _ivreg2_accelerated_term

outreg2 using "iv_course_sections_`dv'.xls", append ///
	dec(3) alpha(0.001, 0.01, 0.05) ///
	addtext(IV Stage, First, IV is Last..., Term, Total Students..., ln) ///
	keep(pct_sections_7wk_last_term ln_tot_sections_last_term)
}

	* Percent of Sections Offered Last Year as IV
	*********************************************

foreach dv of varlist pass_rate fail_rate withdrawal grade_points {

ivreg2 `dv' (accelerated_term = pct_sections_7wk_last_year ///
	ln_tot_sections_last_year) ///
	i.institution i.term_code i.modality_fe i.fe_subject_code ///
	`control_vars', first savefirst

outreg2 using "iv_course_sections_`dv'.xls", append ///
	dec(3) alpha(0.001, 0.01, 0.05) ///
	addtext(IV Stage, Second, IV is Last..., Year, Total Students..., ln) ///
	keep(accelerated_term)
est restore _ivreg2_accelerated_term

outreg2 using "iv_course_sections_`dv'.xls", append ///
	dec(3) alpha(0.001, 0.01, 0.05) ///
	addtext(IV Stage, First, IV is Last..., Year, Total Students..., ln) ///
	keep(pct_sections_7wk_last_year ln_tot_sections_last_year)

}

log close

}

*****************************************************************************
** ROBUSTNESS - BOTH FORMATS
*****************************************************************************

if `table6_robus_bothfmts' == 1 { 

*************************************************
* The following code was used to generate Table 6
*************************************************

cd "${output}"
log using "Robustness_Formats_Enrollment.smcl", replace

* Load in the data
******************

use "${dta}analytic_dataset.dta", clear

* Subsample of courses offered in both formats
**********************************************

	* Identify courses offered in both formats at the same college
bysort course_fe institution: egen course_inst_15wk = min(accelerated_term)
bysort course_fe institution: egen course_inst_7wk = max(accelerated_term)
g course_inst_15and7 = course_inst_15wk == 0 & course_inst_7wk == 1

	* Identify courses offered in both formats at the same college 
	* in the same modality
bysort course_fe institution instructional_method_collapsed: ///
	egen course_inst_modality_15wk = min(accelerated_term)
bysort course_fe institution instructional_method_collapsed: ///
	egen course_inst_modality_7wk = max(accelerated_term)
g course_inst_modality_15and7 = course_inst_modality_15wk == 0 & ///
	course_inst_modality_7wk == 1
	
* Run robustness analyses
*************************

	* Define covariate local
local control_vars age_25plus female asian black hisp multi ///
	race_oth_under1000 pell_recipient ls_math_required ///
	ls_reading_required ls_writing_required ///
	hs_gpa_models hs_gpa_models_missing full_time ft_fresh

	* Naive model to provide control mean -- it's the constant in this model
reg pass_rate accelerated_term if course_inst_15and7 == 1, vce(robust)
outreg2 using subsample_both15and7.xls, replace keep(accelerated_term) ///
	dec(3) alpha(0.001, 0.01, 0.05)
	
	* Subsample of courses offered in both formats at same college
	* FEs: institution, term by year, modality, course
areg pass_rate accelerated_term `control_vars' i.institution i.term_code ///
	i.modality_fe if course_inst_15and7 == 1, absorb(course_fe) vce(robust)
outreg2 using subsample_both15and7.xls, append keep(accelerated_term) ///
	addtext(Control Variables, YES, Institution FE, YES, Term by Year FE, ///
	YES, Course Subj & Num FE, YES, Modality FE, YES) ///
	dec(3) alpha(0.001, 0.01, 0.05)

	* Subsample of courses offered in both formats at same college
	* FEs: institution, term by year, modality, student
areg pass_rate accelerated_term `control_vars' i.institution i.term_code ///
	i.modality_fe if course_inst_15and7 == 1, absorb(student_id) vce(robust)
outreg2 using subsample_both15and7.xls, append keep(accelerated_term) ///
	addtext(Control Variables, YES, Institution FE, YES, Term by Year FE, ///
	YES, Modality FE, YES, Student FE, YES) ///
	dec(3) alpha(0.001, 0.01, 0.05)
	
	* Subsample of courses offered in both formats at same college
	* FEs: institution, term by year, modality, student, twodig cip fe
areg pass_rate accelerated_term `control_vars' i.institution i.term_code ///
	i.modality_fe i.twodig_cip if course_inst_15and7 == 1, ///
		absorb(student_id) vce(robust)
outreg2 using subsample_both15and7.xls, append keep(accelerated_term) ///
	addtext(Control Variables, YES, Institution FE, YES, Term by Year FE, ///
	YES, Modality FE, YES, Student FE, YES, CIP Code FE, YES) ///
	dec(3) alpha(0.001, 0.01, 0.05)
	
	* Naive model to provide control mean -- it's the constant in this model
reg pass_rate accelerated_term if course_inst_modality_15and7 == 1, vce(robust)
outreg2 using subsample_both15and7.xls, append keep(accelerated_term) ///
	dec(3) alpha(0.001, 0.01, 0.05)
	
	* Subsample of courses offered in both formats at the same college 
	* in the same modality
	* FEs: institution, term by year, modality, course
areg pass_rate accelerated_term `control_vars' i.institution i.term_code ///
	i.modality_fe if course_inst_modality_15and7 == 1, ///
	absorb(course_fe) vce(robust)
outreg2 using subsample_both15and7.xls, append keep(accelerated_term) ///
	addtext(Control Variables, YES, Institution FE, YES, Term by Year FE, ///
	YES, Course Subj & Num FE, YES, Modality FE, YES) ///
	dec(3) alpha(0.001, 0.01, 0.05)
	
	* Subsample of courses offered in both formats at same college
	* FEs: institution, term by year, modality, student
areg pass_rate accelerated_term `control_vars' i.institution i.term_code ///
	i.modality_fe if course_inst_modality_15and7 == 1, absorb(student_id) ///
	vce(robust)
outreg2 using subsample_both15and7.xls, append keep(accelerated_term) ///
	addtext(Control Variables, YES, Institution FE, YES, Term by Year FE, ///
	YES, Modality FE, YES, Student FE, YES) ///
	dec(3) alpha(0.001, 0.01, 0.05)
	
	* Subsample of courses offered in both formats at same college
	* FEs: institution, term by year, modality, student, twodig cip fe
areg pass_rate accelerated_term `control_vars' i.institution i.term_code ///
	i.modality_fe i.twodig_cip if course_inst_modality_15and7 == 1, ///
	absorb(student_id) vce(robust)
outreg2 using subsample_both15and7.xls, append keep(accelerated_term) ///
	addtext(Control Variables, YES, Institution FE, YES, Term by Year FE, ///
	YES, Modality FE, YES, Student FE, YES, CIP Code FE, YES) ///
	dec(3) alpha(0.001, 0.01, 0.05)
	
foreach var of varlist fail_rate withdrawal grade_points {
	
	* Naive model to provide control mean -- it's the constant in this model
reg `var' accelerated_term if course_inst_15and7 == 1, vce(robust)
outreg2 using subsample_both15and7.xls, append keep(accelerated_term) ///
	dec(3) alpha(0.001, 0.01, 0.05)

	* Subsample of courses offered in both formats at same college
	* FEs: institution, term by year, modality, course
areg `var' accelerated_term `control_vars' i.institution i.term_code ///
	i.modality_fe if course_inst_15and7 == 1, absorb(course_fe) vce(robust)
outreg2 using subsample_both15and7.xls, append keep(accelerated_term) ///
	addtext(Control Variables, YES, Institution FE, YES, Term by Year FE, ///
	YES, Course Subj & Num FE, YES, Modality FE, YES) ///
	dec(3) alpha(0.001, 0.01, 0.05)

	* Subsample of courses offered in both formats at same college
	* FEs: institution, term by year, modality, student
areg `var' accelerated_term `control_vars' i.institution i.term_code ///
	i.modality_fe if course_inst_15and7 == 1, absorb(student_id) vce(robust)
outreg2 using subsample_both15and7.xls, append keep(accelerated_term) ///
	addtext(Control Variables, YES, Institution FE, YES, Term by Year FE, ///
	YES, Modality FE, YES, Student FE, YES) ///
	dec(3) alpha(0.001, 0.01, 0.05)

	* Subsample of courses offered in both formats at same college
	* FEs: institution, term by year, modality, student, twodig cip fe
areg `var' accelerated_term `control_vars' i.institution i.term_code ///
	i.modality_fe i.twodig_cip if course_inst_15and7 == 1, ///
	absorb(student_id) vce(robust)
outreg2 using subsample_both15and7.xls, append keep(accelerated_term) ///
	addtext(Control Variables, YES, Institution FE, YES, Term by Year FE, ///
	YES, Modality FE, YES, Student FE, YES, CIP Code FE, YES) ///
	dec(3) alpha(0.001, 0.01, 0.05)

	* Naive model to provide control mean -- it's the constant in this model
reg `var' accelerated_term if course_inst_modality_15and7 == 1, vce(robust)
outreg2 using subsample_both15and7.xls, append keep(accelerated_term) ///
	dec(3) alpha(0.001, 0.01, 0.05)
	
	* Subsample of courses offered in both formats at the same college 
	* in the same modality
	* FEs: institution, term by year, modality, course
areg `var' accelerated_term `control_vars' i.institution i.term_code ///
	i.modality_fe if course_inst_modality_15and7 == 1, ///
	absorb(course_fe) vce(robust)
outreg2 using subsample_both15and7.xls, append keep(accelerated_term) ///
	addtext(Control Variables, YES, Institution FE, YES, Term by Year FE, ///
	YES, Course Subj & Num FE, YES, Modality FE, YES) ///
	dec(3) alpha(0.001, 0.01, 0.05)
	
	* Subsample of courses offered in both formats at same college
	* FEs: institution, term by year, modality, student
areg `var' accelerated_term `control_vars' i.institution i.term_code ///
	i.modality_fe if course_inst_modality_15and7 == 1, ///
	absorb(student_id) vce(robust)
outreg2 using subsample_both15and7.xls, append keep(accelerated_term) ///
	addtext(Control Variables, YES, Institution FE, YES, Term by Year FE, ///
	YES, Modality FE, YES, Student FE, YES) ///
	dec(3) alpha(0.001, 0.01, 0.05)
	
	* Subsample of courses offered in both formats at same college
	* FEs: institution, term by year, modality, student, twodig cip fe
areg `var' accelerated_term `control_vars' i.institution i.term_code ///
	i.modality_fe i.twodig_cip if course_inst_modality_15and7 == 1, ///
	absorb(student_id) vce(robust)
outreg2 using subsample_both15and7.xls, append keep(accelerated_term) ///
	addtext(Control Variables, YES, Institution FE, YES, Term by Year FE, ///
	YES, Modality FE, YES, Student FE, YES, CIP Code FE, YES) ///
	dec(3) alpha(0.001, 0.01, 0.05)
	
} 	

log close

}

********************************************************************************
** ROBUSTNESS - EXCLUDING CHATTANOOGA
********************************************************************************

if `table7_robus_byschool' == 1 { 

*************************************************
* The following code was used to generate Table 7
*************************************************

cd "${output}"
log using "Robust_Inst_Enrollment.smcl", replace

* Load in the data
******************

use "${dta}analytic_dataset.dta", clear

* Share of 7-week enrollments that are from Chattanooga
ta institution accelerated_term, m col
bysort accelerated_term: tabstat chattanooga, statistics(mean) ///
	by(term_code)
ta institution accelerated_term, m r
bysort institution: tabstat accelerated_term, statistics(mean) ///
	by(term_code)

	* Define covariate local
local control_vars age_25plus pell_recipient female asian black hisp ///
	multi race_oth_under1000 full_time ft_fresh ///
	ls_math_required ls_reading_required ls_writing_required ///
	hs_gpa_models hs_gpa_models_missing
	
* Run Full-Sample Models
************************

	* Run Pass Rate Models
	**********************
	
	* FEs: institution, term, modality, and course
areg pass_rate accelerated_term `control_vars' i.institution ///
	i.term_code i.modality_fe, absorb(course_fe) vce(robust)
outreg2 using "course_enrollment_without_chatt.xls", replace ///
	ctitle(pass_rate) ///
	addtext(Covariates, YES, Inst FE, YES, Term-Year FE, YES, Course FE, ///
	YES, Modality FE, YES) ///
	dec(3) alpha(0.001, 0.01, 0.05)	
	
	* FEs: institution, term, modality, two-digit course CIP code, and student
areg pass_rate accelerated_term `control_vars' i.institution i.term_code ///
	i.modality_fe i.twodig_cip, ///
	absorb(student_id) vce(robust)
outreg2 using "course_enrollment_without_chatt.xls", append ///
	ctitle(pass_rate) ///
	addtext(Covariates, YES, Inst FE, YES, Modality FE, YES, Term-Year FE, ///
	YES, Student FE, YES, CIP Code FE, YES) ///
	dec(3) alpha(0.001, 0.01, 0.05)	

	* Run Remaining DVs
	*******************
	
foreach dv of varlist fail_rate withdrawal grade_points {
		
	* FEs: institution, term, modality, and course
areg `dv' accelerated_term `control_vars' i.institution ///
	i.term_code i.modality_fe, absorb(course_fe) vce(robust)
outreg2 using "course_enrollment_without_chatt.xls", append ctitle(`dv') ///
	addtext(Covariates, YES, Inst FE, YES, Term-Year FE, YES, Course FE, ///
	YES, Modality FE, YES) ///
	dec(3) alpha(0.001, 0.01, 0.05)	
	
	* FEs: institution, term, modality, two-digit course CIP code, and student
areg `dv' accelerated_term `control_vars' i.institution i.term_code ///
	i.modality_fe i.twodig_cip, absorb(student_id) vce(robust)
outreg2 using "course_enrollment_without_chatt.xls", ///
	append ctitle(`dv') ///
	addtext(Covariates, YES, Inst FE, YES, Modality FE, YES, Term-Year FE, ///
	YES, Student FE, YES, CIP Code FE, YES) ///
	dec(3) alpha(0.001, 0.01, 0.05)	

} 	

* Run Models Excluding Chattanooga
**********************************

	* Drop Chattanooga
drop if chattanooga==1

	* Run models minus Chattanooga
	******************************
	
foreach dv of varlist pass_rate fail_rate withdrawal grade_points {

	* naive OLS	-- control mean is the _cons in this model		
reg `dv' accelerated_term, robust 
outreg2 using "course_enrollment_without_chatt.xls", append ctitle(`dv') ///
	dec(3) alpha(0.001, 0.01, 0.05)

	* FEs: institution, term, modality, and course
areg `dv' accelerated_term `control_vars' i.institution ///
	i.term_code i.modality_fe, absorb(course_fe) vce(robust)
outreg2 using "course_enrollment_without_chatt.xls", append ctitle(`dv') ///
	addtext(Covariates, YES, Inst FE, YES, Term-Year FE, YES, Course FE, ///
	YES, Modality FE, YES) ///
	dec(3) alpha(0.001, 0.01, 0.05)	
	
	* FEs: institution, term, modality, two-digit course CIP code, and student
areg `dv' accelerated_term `control_vars' i.institution i.term_code ///
	i.modality_fe i.twodig_cip, absorb(student_id) vce(robust)
outreg2 using "course_enrollment_without_chatt.xls", append ctitle(`dv') ///
	addtext(Covariates, YES, Inst FE, YES, Modality FE, YES, Term-Year FE, ///
	YES, Student FE, YES, CIP Code FE, YES) ///
	dec(3) alpha(0.001, 0.01, 0.05)	

} 	

* Run Models Only for Chattanooga
*********************************

* Load in the data
******************

use "${dta}analytic_dataset.dta", clear

	* Keep Only Chattanooga
keep if chattanooga==1

	* Run models minus Chattanooga
	******************************

	* naive OLS	-- control mean is the _cons in this model		
reg pass_rate accelerated_term, robust 
outreg2 using "course_enrollment_chatt_only.xls", replace ctitle(pass_rate) ///
	dec(3) alpha(0.001, 0.01, 0.05)

	* FEs: institution, term, modality, and course
areg pass_rate accelerated_term `control_vars' i.institution ///
	i.term_code i.modality_fe, absorb(course_fe) vce(robust)
outreg2 using "course_enrollment_chatt_only.xls", append ctitle(pass_rate) ///
	addtext(Covariates, YES, Inst FE, YES, Term-Year FE, YES, Course FE, ///
	YES, Modality FE, YES) ///
	dec(3) alpha(0.001, 0.01, 0.05)	
	
	* FEs: institution, term, modality, two-digit course CIP code, and student
areg pass_rate accelerated_term `control_vars' i.institution i.term_code ///
	i.modality_fe i.twodig_cip, absorb(student_id) vce(robust)
outreg2 using "course_enrollment_chatt_only.xls", append ctitle(pass_rate) ///
	addtext(Covariates, YES, Inst FE, YES, Modality FE, YES, Term-Year FE, ///
	YES, Student FE, YES, CIP Code FE, YES) ///
	dec(3) alpha(0.001, 0.01, 0.05)	

foreach dv of varlist fail_rate withdrawal grade_points {

	* naive OLS	-- control mean is the _cons in this model		
reg `dv' accelerated_term, robust 
outreg2 using "course_enrollment_chatt_only.xls", append ctitle(`dv') ///
	dec(3) alpha(0.001, 0.01, 0.05)

	* FEs: institution, term, modality, and course
areg `dv' accelerated_term `control_vars' i.institution ///
	i.term_code i.modality_fe, absorb(course_fe) vce(robust)
outreg2 using "course_enrollment_chatt_only.xls", append ctitle(`dv') ///
	addtext(Covariates, YES, Inst FE, YES, Term-Year FE, YES, Course FE, ///
	YES, Modality FE, YES) ///
	dec(3) alpha(0.001, 0.01, 0.05)	
	
	* FEs: institution, term, modality, two-digit course CIP code, and student
areg `dv' accelerated_term `control_vars' i.institution i.term_code ///
	i.modality_fe i.twodig_cip, absorb(student_id) vce(robust)
outreg2 using "course_enrollment_chatt_only.xls", append ctitle(`dv') ///
	addtext(Covariates, YES, Inst FE, YES, Modality FE, YES, Term-Year FE, ///
	YES, Student FE, YES, CIP Code FE, YES) ///
	dec(3) alpha(0.001, 0.01, 0.05)	

} 	

log close

}

********************************************************************************
***                    PART II: STUDENT-LEVEL ANALYSES                       ***
********************************************************************************

********************************************************************************
** SAMPLE RESTRICTION & IMPACT ON SAMPLE SIZE - STUDENT LEVEL
********************************************************************************

if `apptab2_panelb_samprest' == 1 { 

*******************************************************************
* The following code was used to generate Appendix Table 2, Panel B
*******************************************************************

cd "${output}"
log using "SampleRestrictions_Students.smcl", replace

/* We'll merge the analytic dataset with the cohort-based outcomes dataset to 
derive another series of main independent variables for each term:
	* Proportion of credit hours in 7-week format of all credit hours */

* Start with the cohort-based outcomes dataset
use "${dta}cohort_based_outcomes_clean.dta", clear
unique student_id 

* Merge with the enrollment-level dataset
merge 1:1 student_id using "${dta}hrs_by_term_cohort_analysis.dta"
	* 1,638 students did not merge - not in enrollment-level analytic data
	* This means they were only enrolled in courses we excluded from analysis
	* (at least during their first-time freshman semester)
keep if _merge==3
drop _merge
unique student_id // 155,493 students from the enrollment-level data are in the
				  // student-level data
	* Being in the student-level data means they are (1) in the enrollment-level 
	* dataset (aka in the analytic sample) and (2) they are first-time freshmen
	* --> This is the first exclusion entry in the student-level section of the
	* selection table

* Because our definition of accelerated courses excludes summer, carry forward 
* the number of accelerated hours, courses, and accelerated indicator from  
* spring to summer
g t3_ever_taken_7wk = t2_ever_taken_7wk
g t6_ever_taken_7wk = t5_ever_taken_7wk
g t9_ever_taken_7wk = t8_ever_taken_7wk
g t12_ever_taken_7wk = t11_ever_taken_7wk
g t15_ever_taken_7wk = t14_ever_taken_7wk
g t18_ever_taken_7wk = t17_ever_taken_7wk
g t3_7wk_hours_cumu = t2_7wk_hours_cumu
g t6_7wk_hours_cumu = t5_7wk_hours_cumu
g t9_7wk_hours_cumu = t8_7wk_hours_cumu
g t12_7wk_hours_cumu = t11_7wk_hours_cumu
g t15_7wk_hours_cumu = t14_7wk_hours_cumu
g t18_7wk_hours_cumu = t17_7wk_hours_cumu
g t3_7wk_courses_cumu_iv = t2_7wk_courses_cumu_iv
g t6_7wk_courses_cumu_iv = t5_7wk_courses_cumu_iv
g t9_7wk_courses_cumu_iv = t8_7wk_courses_cumu_iv
g t12_7wk_courses_cumu_iv = t11_7wk_courses_cumu_iv
g t15_7wk_courses_cumu_iv = t14_7wk_courses_cumu_iv
g t18_7wk_courses_cumu_iv = t17_7wk_courses_cumu_iv
g t3_7wk_courses_cumu = t2_7wk_courses_cumu
g t6_7wk_courses_cumu = t5_7wk_courses_cumu
g t9_7wk_courses_cumu = t8_7wk_courses_cumu
g t12_7wk_courses_cumu = t11_7wk_courses_cumu
g t15_7wk_courses_cumu = t14_7wk_courses_cumu
g t18_7wk_courses_cumu = t17_7wk_courses_cumu

* Carry the cumulative hours forward to all future semesters
replace t2_cumu_credits_atmp = total_degree_credits if ///
	(t2_cumu_credits_atmp == . | t2_cumu_credits_atmp == 0)
replace t3_cumu_credits_atmp = t2_cumu_credits_atmp if ///
	(t3_cumu_credits_atmp == . | t3_cumu_credits_atmp == 0)
replace t4_cumu_credits_atmp = t3_cumu_credits_atmp if ///
	(t4_cumu_credits_atmp == . | t4_cumu_credits_atmp == 0)
replace t5_cumu_credits_atmp = t4_cumu_credits_atmp if ///
	(t5_cumu_credits_atmp == . | t5_cumu_credits_atmp == 0)
replace t6_cumu_credits_atmp = t5_cumu_credits_atmp if ///
	(t6_cumu_credits_atmp == . | t6_cumu_credits_atmp == 0)
replace t7_cumu_credits_atmp = t6_cumu_credits_atmp if ///
	(t7_cumu_credits_atmp == . | t7_cumu_credits_atmp == 0)
replace t8_cumu_credits_atmp = t7_cumu_credits_atmp if ///
	(t8_cumu_credits_atmp == . | t8_cumu_credits_atmp == 0)
replace t9_cumu_credits_atmp = t8_cumu_credits_atmp if ///
	(t9_cumu_credits_atmp == . | t9_cumu_credits_atmp == 0)
replace t10_cumu_credits_atmp = t9_cumu_credits_atmp if ///
	(t10_cumu_credits_atmp == . | t10_cumu_credits_atmp == 0)
replace t11_cumu_credits_atmp = t10_cumu_credits_atmp if ///
	(t11_cumu_credits_atmp == . | t11_cumu_credits_atmp == 0)
replace t12_cumu_credits_atmp = t11_cumu_credits_atmp if ///
	(t12_cumu_credits_atmp == . | t12_cumu_credits_atmp == 0)

* Generate generate the proportion of credit hours attempted in a 7-week format 
* of all credit hours attempted
g t1_pct_atmp_7wk = t1_7wk_hours_cumu / total_degree_credits
replace t1_pct_atmp_7wk = t1_7wk_hours_cumu / t1_cumu_credits_atmp ///
	if t1_pct_atmp_7wk > 1 // 38 changes made
replace t1_pct_atmp_7wk = 1 if t1_pct_atmp_7wk == . // 1 change made

foreach term in "t2" "t3" "t4" "t5" "t6" "t7" "t8" "t9" "t10" "t11" "t12" {
g `term'_pct_atmp_7wk = `term'_7wk_hours_cumu / `term'_cumu_credits_atmp
replace `term'_pct_atmp_7wk = 1 if `term'_pct_atmp_7wk > 1 & ///
	`term'_pct_atmp_7wk != . // 13-24 changes made
}

* Keep only the students with non-missing values for all three term 1 DVs
keep if dv_t1_term_gpa != . & dv_t1_cumu_home_tran_gpa != . & ///
	dv_t1_pct_earned != . 
unique student_id
	* 742 obs deleted (0.5% of FTF); 154,751 obs remaining
		* --> This is the second exclusion entry in the student-level section of 
		* the selection table
	
* Merge with the covariate dataset
merge 1:1 student_id using "${dta}cohort_analysis_covariates.dta"
	* not matched because not in student-level sample: 304,994
	* matched: 154,751
keep if _merge==3
drop _merge

* Clean high school GPA

g hs_gpa_models = hs_gpa_clean
g hs_gpa_models_missing = hs_gpa_clean == .
su hs_gpa_clean, detail
replace hs_gpa_models = r(p50) if hs_gpa_models == .
bysort hs_gpa_models_missing: su hs_gpa_models, detail
la var hs_gpa_clean "HS GPA (Clean)"
la var hs_gpa_models "HS GPA"
la var hs_gpa_models_missing "HS GPA Missing"

* Count the unduplicated students in this file
unique student_id if t1_term_code >= 201580 & t1_term_code <= 202180
	* 138,945 observations
		* --> This is the third exclusion entry in the student-level section of 
		* the selection table (final analytic sample)
g insample = t1_term_code >= 201580 & t1_term_code <= 202180

* Save the analytic dataset
save "${dta}cohort_analytic_dataset.dta", replace

log close

}

*****************************************************************************
** BASE DESCRIPTIVES - STUDENT LEVEL
*****************************************************************************

if `table1_stud_descriptives' == 1 { 

********************************************************************************
* The following code was used to generate Table 1 for Student-Level Descriptives
********************************************************************************

cd "${output}"
log using "Descriptives_Students.smcl", replace

* Load in the data
******************

use "${dta}cohort_analytic_dataset.dta", clear

	* To keep a consistent sample, keep only fall cohorts 2015-2021
	* (this is the same as keep if insample==1)
drop if t1_term_code == 202280

asdoc tabstat age_25plus pell_recipient female asian black hisp multi ///
	race_oth_under1000 white full_time_in_first_term ///
	ls_number ls_math_required ls_reading_required ls_writing_required ///
	hs_gpa_clean hs_gpa_models_missing, ///
		stat(mean sd count) dec(2) c(statistics) label ///
		save(table1_descriptives_stud.doc) replace

log close

}

*****************************************************************************
** SELECTION - STUDENT LEVEL
*****************************************************************************

if `table2_stud_selection' ==1 { 

**************************************************************************
* The following code was used to generate Table 2, Student-Level Selection
**************************************************************************

cd "${output}"
log using "Selection_Students.smcl", replace

* Load in the data
******************

use "${dta}cohort_analytic_dataset.dta", clear

	* To keep a consistent sample, keep only cohort 2015-2021
	* (this is the same as keep if insample==1)
drop if t1_term_code == 202280

	* Create a global macro with all the covariates
gl covariates pell_recipient female asian black hisp multi ///
	race_oth_under1000 white full_time_in_first_term ///
	ls_number ls_math_required ls_reading_required ls_writing_required ///
	hs_gpa_clean hs_gpa_models_missing

/* Omitted categories:
	-Race: white
	-Gender: male & unknown
	-Age: Under 25
	-Pell: non-recipient */

* Binary IV (2015-2021 cohorts, accelerated in term 1)
******************************************************

* Control mean and treatment mean
bysort t1_ever_taken_7wk: su age_25plus

* Naive OLS to get the control mean -- Constant (_cons) in this regression	
reg age_25plus t1_ever_taken_7wk, robust 
outreg2 using ///
	"selection_studentlevel_binary_iv_acc_term1_2015_2021_controlmean.xls", ///
	excel replace ///
	dec(3) alpha(0.001, 0.01, 0.05)
	
foreach control of varlist $covariates {
	
* Control mean and treatment mean
bysort t1_ever_taken_7wk: su `control'

* Naive OLS to get the control mean -- Constant (_cons) in this regression	
reg `control' t1_ever_taken_7wk, robust 
outreg2 using ///
	"selection_studentlevel_binary_iv_acc_term1_2015_2021_controlmean.xls", ///
	excel append ///
	dec(3) alpha(0.001, 0.01, 0.05)
	
}

* DV: student is age 25+ (0/1)
* IV: ever taken 7-week courses in term 12/within 4 years of initial enrollment 
* (0/1)
areg age_25plus t1_ever_taken_7wk, a(fe_cohort_inst) robust
outreg2 using ///
	"selection_studentlevel_binary_iv_acc_term1_2015_2021.xls", replace ///
	keep(t1_ever_taken_7wk) ///
	addtext(Cohort by Institution FE, YES) dec(3) alpha(0.001, 0.01, 0.05) 
	
foreach control of varlist $covariates {

* DV: looping through student-level covariates
* IV: ever taken 7-week courses in term 12/within 4 years of initial enrollment 
* (0/1)
areg `control' t1_ever_taken_7wk, a(fe_cohort_inst) robust
outreg2 using "selection_studentlevel_binary_iv_acc_term1_2015_2021.xls", ///
	append keep(t1_ever_taken_7wk) ///
	addtext(Cohort by Institution FE, YES) dec(3) alpha(0.001, 0.01, 0.05) 
	
}

* Discrete IV
*************

* Change the discrete IV to 0, 1, or 2+ 7-week courses
foreach var of varlist *7wk_courses_cumu_iv {
replace `var' = 2 if `var' > 2 & `var' != .
}

label define lab_7wk_courses_cumu_iv ///
	0 "0 7-Week Courses" 1 "1 7-Week Course" 2 "2+ 7-Week Courses"
label values *_7wk_courses_cumu_iv lab_7wk_courses_cumu_iv

* Discrete IV (2015-2021 cohorts, accelerated in term 1)
********************************************************

* Control mean and treatment mean
bysort t1_ever_taken_7wk: su age_25plus

* Naive OLS to get the control mean -- Constant (_cons) in this regression	
reg age_25plus i.t1_7wk_courses_cumu_iv, robust 
outreg2 using ///
	"selection_studentlevel_discrete_iv_acc_term1_2015_2021_controlmean.xls", ///
	excel replace ///
	dec(3) alpha(0.001, 0.01, 0.05)
	
foreach control of varlist $covariates {

* Control mean and treatment mean
bysort t1_ever_taken_7wk: su `control'

* Naive OLS to get the control mean -- Constant (_cons) in this regression	
reg `control' i.t1_7wk_courses_cumu_iv, robust 
test 1.t1_7wk_courses_cumu_iv = 2.t1_7wk_courses_cumu_iv
outreg2 using ///
	"selection_studentlevel_discrete_iv_acc_term1_2015_2021_controlmean.xls", ///
	excel append ///
	dec(3) alpha(0.001, 0.01, 0.05)
	
}

* DV: student is age 25+ (0/1)
* IV: cumulative number of 7-week courses taken in term 1 (0, 1, or 2+)
areg age_25plus i.t1_7wk_courses_cumu_iv, a(fe_cohort_inst) robust
test 1.t1_7wk_courses_cumu_iv = 2.t1_7wk_courses_cumu_iv
outreg2 using "selection_studentlevel_discrete_iv_acc_term1_2015_2021.xls", ///
	replace keep(1.t1_7wk_courses_cumu_iv 2.t1_7wk_courses_cumu_iv) ///
	addtext(Cohort by Institution FE, YES) dec(3) alpha(0.001, 0.01, 0.05) 

foreach control of varlist $covariates {
	
* DV: looping through student-level covariates
* IV: cumulative number of 7-week courses taken in term 1 (0, 1, or 2+)
areg `control' i.t1_7wk_courses_cumu_iv, a(fe_cohort_inst) robust
test 1.t1_7wk_courses_cumu_iv = 2.t1_7wk_courses_cumu_iv
outreg2 using "selection_studentlevel_discrete_iv_acc_term1_2015_2021.xls", ///
	append keep(1.t1_7wk_courses_cumu_iv 2.t1_7wk_courses_cumu_iv) ///
	addtext(Cohort by Institution FE, YES) dec(3) alpha(0.001, 0.01, 0.05) 

}

log close

}

*****************************************************************************
** MAIN ANALYSIS - STUDENT-LEVEL FIXED EFFECTS
*****************************************************************************

if `table5_stud_femodels' == 1 { 

******************************************************************************
* The following code was used to generate Table 5, Student-Level Fixed Effects
******************************************************************************

cd "${output}"
log using "ModelsBinary_1521_Students.smcl", replace

* Load in the dataset
*********************

use "${dta}cohort_analytic_dataset.dta", clear

* To keep a consistent sample, keep only cohort 2015-2021
drop if t1_term_code == 202280

* Create a global macro with all the covariates
gl covariates age_25plus pell_recipient female asian black hisp multi ///
	race_oth_under1000 full_time_in_first_term ///
	ls_math_required ls_reading_required ls_writing_required ///
	hs_gpa_models hs_gpa_models_missing twodig_cip_major_unknown ///
	i.twodig_cip_major

/* Omitted categories:
	-Race: white
	-Gender: male & unknown
	-Age: Under 25
	-Pell: non-recipient */

********************************************************************************
* Binary IV
********************************************************************************

* Set globals for models
gl t1_dv t1_ever_taken_7wk
gl output_file_name cohorts_main_results_binary_iv_acc_term1_2015-2021.xls

* Identify SDs for continuous control vars 
bysort t1_ever_taken_7wk: su dv_t1_term_gpa dv_y1_cumu_home_tran_gpa

* DV: term GPA, term 1
* IV: ever taken 7-week courses in term 1 (0/1)
reg dv_t1_term_gpa $t1_dv, robust
outreg2 using "$output_file_name", replace keep($t1_dv) ///
	dec(3) alpha(0.001, 0.01, 0.05) 
areg dv_t1_term_gpa $t1_dv $covariates, a(fe_cohort_inst) robust
outreg2 using "$output_file_name", append keep($t1_dv) ///
	addtext(Cohort by Institution FE, YES, Covariates Included, YES) dec(3) ///
	alpha(0.001, 0.01, 0.05) 

* DV: cumulative GPA, term 1 (home + transfer hours)
* IV: ever taken 7-week courses in term 1 (0/1)
reg dv_t1_cumu_home_tran_gpa $t1_dv, robust
outreg2 using "$output_file_name", append keep($t1_dv) ///
	dec(3) alpha(0.001, 0.01, 0.05) 
areg dv_t1_cumu_home_tran_gpa $t1_dv $covariates, a(fe_cohort_inst) robust
outreg2 using "$output_file_name", append keep($t1_dv) ///
	addtext(Cohort by Institution FE, YES, Covariates Included, YES) dec(3) ///
	alpha(0.001, 0.01, 0.05) 

* DV: percent of attempted hours earned, term 1
* IV: ever taken 7-week courses in term 1 (0/1)
reg dv_t1_pct_earned $t1_dv, robust
outreg2 using "$output_file_name", append keep($t1_dv) ///
	dec(3) alpha(0.001, 0.01, 0.05) 
areg dv_t1_pct_earned $t1_dv $covariates, a(fe_cohort_inst) robust
outreg2 using "$output_file_name", append keep($t1_dv) ///
	addtext(Cohort by Institution FE, YES, Covariates Included, YES) dec(3) ///
	alpha(0.001, 0.01, 0.05) 
	
* DV: persistence to term 2 (first spring)
* IV: ever taken 7-week courses in term 1 (0/1)
reg dv_persist_t2 $t1_dv, robust
outreg2 using "$output_file_name", append keep($t1_dv) ///
	dec(3) alpha(0.001, 0.01, 0.05) 
areg dv_persist_t2 $t1_dv $covariates, a(fe_cohort_inst) robust
outreg2 using "$output_file_name", append keep($t1_dv) ///
	addtext(Cohort by Institution FE, YES, Covariates Included, YES) dec(3) ///
	alpha(0.001, 0.01, 0.05) 
	
* DV: cumulative GPA, year 1 (home + transfer hours)
* IV: ever taken 7-week courses in term 3 (0/1)
reg dv_y1_cumu_home_tran_gpa $t1_dv, robust
outreg2 using "$output_file_name", append keep($t1_dv) ///
	dec(3) alpha(0.001, 0.01, 0.05) 
areg dv_y1_cumu_home_tran_gpa $t1_dv $covariates, a(fe_cohort_inst) robust
outreg2 using "$output_file_name", append keep($t1_dv) ///
	addtext(Cohort by Institution FE, YES, Covariates Included, YES) dec(3) ///
	alpha(0.001, 0.01, 0.05) 

* DV: percent of attempted hours earned, year 1
* IV: ever taken 7-week courses in term 3 (0/1)
reg dv_y1_pct_earned $t1_dv, robust
outreg2 using "$output_file_name", append keep($t1_dv) ///
	dec(3) alpha(0.001, 0.01, 0.05) 
areg dv_y1_pct_earned $t1_dv $covariates, a(fe_cohort_inst) robust
outreg2 using "$output_file_name", append keep($t1_dv) ///
	addtext(Cohort by Institution FE, YES, Covariates Included, YES) dec(3) ///
	alpha(0.001, 0.01, 0.05)
	
* DV: persistence to term 4 (second fall)
* IV: ever taken 7-week courses in term 3 (0/1)
reg dv_persist_t4 $t1_dv, robust
outreg2 using "$output_file_name", append keep($t1_dv) ///
	dec(3) alpha(0.001, 0.01, 0.05) 
areg dv_persist_t4 $t1_dv $covariates, a(fe_cohort_inst) robust
outreg2 using "$output_file_name", append keep($t1_dv) ///
	addtext(Cohort by Institution FE, YES, Covariates Included, YES) dec(3) ///
	alpha(0.001, 0.01, 0.05) 

* DV: persistence to year 2 (any term in second year)
* IV: ever taken 7-week courses in term 3 (0/1)
reg dv_persist_y2 $t1_dv, robust
outreg2 using "$output_file_name", append keep($t1_dv) ///
	dec(3) alpha(0.001, 0.01, 0.05) 
areg dv_persist_y2 $t1_dv $covariates, a(fe_cohort_inst) robust
outreg2 using "$output_file_name", append keep($t1_dv) ///
	addtext(Cohort by Institution FE, YES, Covariates Included, YES) dec(3) ///
	alpha(0.001, 0.01, 0.05) 
	
* DV: graduation within 2 years
* IV: ever taken 7-week courses in term 6 (0/1)
reg dv_grad_y2 $t1_dv, robust
outreg2 using "$output_file_name", append keep($t1_dv) ///
	dec(3) alpha(0.001, 0.01, 0.05) 
areg dv_grad_y2 $t1_dv $covariates, a(fe_cohort_inst) robust
outreg2 using "$output_file_name", append keep($t1_dv) ///
	addtext(Cohort by Institution FE, YES, Covariates Included, YES) dec(3) ///
	alpha(0.001, 0.01, 0.05) 
	
* DV: persistence to term 7 (third fall)
* IV: ever taken 7-week courses in term 6 (0/1)
reg dv_persist_t7 $t1_dv, robust
outreg2 using "$output_file_name", append keep($t1_dv) ///
	dec(3) alpha(0.001, 0.01, 0.05) 
areg dv_persist_t7 $t1_dv $covariates, a(fe_cohort_inst) robust
outreg2 using "$output_file_name", append keep($t1_dv) ///
	addtext(Cohort by Institution FE, YES, Covariates Included, YES) dec(3) ///
	alpha(0.001, 0.01, 0.05) 
	
* DV: persistence to year 3 (any term in third year)
* IV: ever taken 7-week courses in term 6 (0/1)
reg dv_persist_y3 $t1_dv, robust
outreg2 using "$output_file_name", append keep($t1_dv) ///
	dec(3) alpha(0.001, 0.01, 0.05) 
areg dv_persist_y3 $t1_dv $covariates, a(fe_cohort_inst) robust
outreg2 using "$output_file_name", append keep($t1_dv) ///
	addtext(Cohort by Institution FE, YES, Covariates Included, YES) dec(3) ///
	alpha(0.001, 0.01, 0.05) 

* DV: graduation within 3 years
* IV: ever taken 7-week courses in term 9 (0/1)
reg dv_grad_y3 $t1_dv, robust
outreg2 using "$output_file_name", append keep($t1_dv) ///
	dec(3) alpha(0.001, 0.01, 0.05) 
areg dv_grad_y3 $t1_dv $covariates, a(fe_cohort_inst) robust
outreg2 using "$output_file_name", append keep($t1_dv) ///
	addtext(Cohort by Institution FE, YES, Covariates Included, YES) dec(3) ///
	alpha(0.001, 0.01, 0.05) 
	
* DV: terms to first completion
* IV: ever taken 7-week courses in term 18 (0/1) 
* --> because we only pulled 18 terms of completions
reg dv_terms_first_completion $t1_dv, robust
outreg2 using "$output_file_name", append keep($t1_dv) ///
	dec(3) alpha(0.001, 0.01, 0.05) 
areg dv_terms_first_completion $t1_dv $covariates, a(fe_cohort_inst) robust
outreg2 using "$output_file_name", append keep($t1_dv) ///
	addtext(Cohort by Institution FE, YES, Covariates Included, YES) dec(3) ///
	alpha(0.001, 0.01, 0.05) 
	
* DV: number of completions
* IV: ever taken 7-week courses in term 18 (0/1)
* --> because we only pulled 18 terms of completions
reg dv_number_completions $t1_dv, robust
outreg2 using "$output_file_name", append keep($t1_dv) ///
	dec(3) alpha(0.001, 0.01, 0.05) 
areg dv_number_completions $t1_dv $covariates, a(fe_cohort_inst) robust
outreg2 using "$output_file_name", append keep($t1_dv) ///
	addtext(Cohort by Institution FE, YES, Covariates Included, YES) dec(3) ///
	alpha(0.001, 0.01, 0.05) 

log close

********************************************************************************
* Discrete IV
********************************************************************************

log using "ModelsDiscrete_1521_StudentLevel.smcl", replace

* Load in the dataset
use "${dta}cohort_analytic_dataset.dta", clear

* To keep a consistent sample, keep only cohort 2015-2021
drop if t1_term_code == 202280

* Change the discrete IV to 0, 1, or 2+ 7-week courses
foreach var of varlist *7wk_courses_cumu_iv {
	replace `var' = 2 if `var' > 2 & `var' != .
}
label define lab_7wk_courses_cumu_iv 0 "0 7-Week Courses" ///
	1 "1 7-Week Course" 2 "2+ 7-Week Courses"
label values *_7wk_courses_cumu_iv lab_7wk_courses_cumu_iv

/* Omitted categories:
	-Race: white
	-Gender: male & unknown
	-Age: Under 25
	-Pell: non-recipient */

* Set globals for models
gl t1_dv t1_7wk_courses_cumu_iv
gl t3_dv t3_7wk_courses_cumu_iv
gl t6_dv t6_7wk_courses_cumu_iv
gl t9_dv t9_7wk_courses_cumu_iv
gl t18_dv t18_7wk_courses_cumu_iv
gl output_file_name cohorts_main_results_discrete_iv_acc_term1_2015_2021.xls

* DV: term GPA, term 1
* IV: number of 7-week courses taken in term 1 (0, 1, or 2+)
reg dv_t1_term_gpa i.$t1_dv, robust
test 1.$t1_dv = 2.$t1_dv
outreg2 using "$output_file_name", replace dec(3) label ///
	keep(1.$t1_dv 2.$t1_dv) alpha(0.001, 0.01, 0.05) 
areg dv_t1_term_gpa i.$t1_dv $covariates, a(fe_cohort_inst) robust
test 1.$t1_dv = 2.$t1_dv
outreg2 using "$output_file_name", append dec(3) label ///
	keep(1.$t1_dv 2.$t1_dv) alpha(0.001, 0.01, 0.05) ///
	addtext(Cohort by Institution FE, YES, Covariates Included, YES) 

* DV: cumulative GPA, term 1 (home + transfer hours)
* IV: number of 7-week courses taken in term 1 (0, 1, or 2+)
reg dv_t1_cumu_home_tran_gpa i.$t1_dv, robust
test 1.$t1_dv = 2.$t1_dv
outreg2 using "$output_file_name", append dec(3) label ///
	keep(1.$t1_dv 2.$t1_dv) alpha(0.001, 0.01, 0.05) 
areg dv_t1_cumu_home_tran_gpa i.$t1_dv $covariates, a(fe_cohort_inst) robust
test 1.$t1_dv = 2.$t1_dv
outreg2 using "$output_file_name", append dec(3) label ///
	keep(1.$t1_dv 2.$t1_dv) alpha(0.001, 0.01, 0.05) ///
	addtext(Cohort by Institution FE, YES, Covariates Included, YES)  

* DV: percent of attempted hours earned, term 1
* IV: number of 7-week courses taken in term 1 (0, 1, or 2+)
reg dv_t1_pct_earned i.$t1_dv, robust
test 1.$t1_dv = 2.$t1_dv
outreg2 using "$output_file_name", append dec(3) label ///
	keep(1.$t1_dv 2.$t1_dv) alpha(0.001, 0.01, 0.05) 
areg dv_t1_pct_earned i.$t1_dv $covariates, a(fe_cohort_inst) robust
test 1.$t1_dv = 2.$t1_dv
outreg2 using "$output_file_name", append dec(3) label ///
	keep(1.$t1_dv 2.$t1_dv) alpha(0.001, 0.01, 0.05) ///
	addtext(Cohort by Institution FE, YES, Covariates Included, YES) 
	
* DV: persistence to term 2 (first spring)
* IV: number of 7-week courses taken in term 1 (0, 1, or 2+)
reg dv_persist_t2 i.$t1_dv, robust
test 1.$t1_dv = 2.$t1_dv
outreg2 using "$output_file_name", append dec(3) label ///
	keep(1.$t1_dv 2.$t1_dv) alpha(0.001, 0.01, 0.05) 
areg dv_persist_t2 i.$t1_dv $covariates, a(fe_cohort_inst) robust
test 1.$t1_dv = 2.$t1_dv
outreg2 using "$output_file_name", append dec(3) label ///
	keep(1.$t1_dv 2.$t1_dv) alpha(0.001, 0.01, 0.05) ///
	addtext(Cohort by Institution FE, YES, Covariates Included, YES) 
	
* DV: cumulative GPA, year 1 (home + transfer hours)
* IV: cumulative number of 7-week courses taken through term 3 (0, 1, or 2+)
reg dv_y1_cumu_home_tran_gpa i.$t1_dv, robust
test 1.$t1_dv = 2.$t1_dv
outreg2 using "$output_file_name", append dec(3) label ///
	keep(1.$t1_dv 2.$t1_dv) alpha(0.001, 0.01, 0.05) 
areg dv_y1_cumu_home_tran_gpa i.$t1_dv $covariates, a(fe_cohort_inst) robust
test 1.$t1_dv = 2.$t1_dv
outreg2 using "$output_file_name", append dec(3) label ///
	keep(1.$t1_dv 2.$t1_dv) alpha(0.001, 0.01, 0.05) ///
	addtext(Cohort by Institution FE, YES, Covariates Included, YES) 

* DV: percent of attempted hours earned, year 1
* IV: cumulative number of 7-week courses taken through term 3 (0, 1, or 2+)
reg dv_y1_pct_earned i.$t1_dv, robust
test 1.$t1_dv = 2.$t1_dv
outreg2 using "$output_file_name", append dec(3) label ///
	keep(1.$t1_dv 2.$t1_dv) alpha(0.001, 0.01, 0.05) 
areg dv_y1_pct_earned i.$t1_dv $covariates, a(fe_cohort_inst) robust
test 1.$t1_dv = 2.$t1_dv
outreg2 using "$output_file_name", append dec(3) label ///
	keep(1.$t1_dv 2.$t1_dv) alpha(0.001, 0.01, 0.05) ///
	addtext(Cohort by Institution FE, YES, Covariates Included, YES) 
	
* DV: persistence to term 4 (second fall)
* IV: cumulative number of 7-week courses taken through term 3 (0, 1, or 2+)
reg dv_persist_t4 i.$t1_dv, robust
test 1.$t1_dv = 2.$t1_dv
outreg2 using "$output_file_name", append dec(3) label ///
	keep(1.$t1_dv 2.$t1_dv) alpha(0.001, 0.01, 0.05) 
areg dv_persist_t4 i.$t1_dv $covariates, a(fe_cohort_inst) robust
test 1.$t1_dv = 2.$t1_dv
outreg2 using "$output_file_name", append dec(3) label ///
	keep(1.$t1_dv 2.$t1_dv) alpha(0.001, 0.01, 0.05) ///
	addtext(Cohort by Institution FE, YES, Covariates Included, YES) 

* DV: persistence to year 2 (any term in second year)
* IV: cumulative number of 7-week courses taken through term 3 (0, 1, or 2+)
reg dv_persist_y2 i.$t1_dv, robust
test 1.$t1_dv = 2.$t1_dv
outreg2 using "$output_file_name", append dec(3) label ///
	keep(1.$t1_dv 2.$t1_dv) alpha(0.001, 0.01, 0.05) 
areg dv_persist_y2 i.$t1_dv $covariates, a(fe_cohort_inst) robust
test 1.$t1_dv = 2.$t1_dv
outreg2 using "$output_file_name", append dec(3) label ///
	keep(1.$t1_dv 2.$t1_dv) alpha(0.001, 0.01, 0.05) ///
	addtext(Cohort by Institution FE, YES, Covariates Included, YES) 
	
* DV: graduation within 2 years
* IV: cumulative number of 7-week courses taken through term 6 (0, 1, or 2+)
reg dv_grad_y2 i.$t1_dv, robust
test 1.$t1_dv = 2.$t1_dv
outreg2 using "$output_file_name", append dec(3) label ///
	keep(1.$t1_dv 2.$t1_dv) alpha(0.001, 0.01, 0.05) 
areg dv_grad_y2 i.$t1_dv $covariates, a(fe_cohort_inst) robust
test 1.$t1_dv = 2.$t1_dv
outreg2 using "$output_file_name", append dec(3) label ///
	keep(1.$t1_dv 2.$t1_dv) alpha(0.001, 0.01, 0.05) ///
	addtext(Cohort by Institution FE, YES, Covariates Included, YES) 
	
* DV: persistence to term 7 (third fall)
* IV: cumulative number of 7-week courses taken through term 6 (0, 1, or 2+)
reg dv_persist_t7 i.$t1_dv, robust
test 1.$t1_dv = 2.$t1_dv
outreg2 using "$output_file_name", append dec(3) label ///
	keep(1.$t1_dv 2.$t1_dv) alpha(0.001, 0.01, 0.05)  
areg dv_persist_t7 i.$t1_dv $covariates, a(fe_cohort_inst) robust
test 1.$t1_dv = 2.$t1_dv
outreg2 using "$output_file_name", append dec(3) label ///
	keep(1.$t1_dv 2.$t1_dv) alpha(0.001, 0.01, 0.05) ///
	addtext(Cohort by Institution FE, YES, Covariates Included, YES) 
	
* DV: persistence to year 3 (any term in third year)
* IV: cumulative number of 7-week courses taken through term 6 (0, 1, or 2+)
reg dv_persist_y3 i.$t1_dv, robust
test 1.$t1_dv = 2.$t1_dv
outreg2 using "$output_file_name", append dec(3) label ///
	keep(1.$t1_dv 2.$t1_dv) alpha(0.001, 0.01, 0.05) 
areg dv_persist_y3 i.$t1_dv $covariates, a(fe_cohort_inst) robust
test 1.$t1_dv = 2.$t1_dv
outreg2 using "$output_file_name", append dec(3) label ///
	keep(1.$t1_dv 2.$t1_dv) alpha(0.001, 0.01, 0.05) ///
	addtext(Cohort by Institution FE, YES, Covariates Included, YES) 

* DV: graduation within 3 years
* IV: cumulative number of 7-week courses taken through term 9 (0, 1, or 2+)
reg dv_grad_y3 i.$t1_dv, robust
test 1.$t1_dv = 2.$t1_dv
outreg2 using "$output_file_name", append dec(3) label ///
	keep(1.$t1_dv 2.$t1_dv) alpha(0.001, 0.01, 0.05)
areg dv_grad_y3 i.$t1_dv $covariates, a(fe_cohort_inst) robust
test 1.$t1_dv = 2.$t1_dv
outreg2 using "$output_file_name", append dec(3) label ///
	keep(1.$t1_dv 2.$t1_dv) alpha(0.001, 0.01, 0.05) ///
	addtext(Cohort by Institution FE, YES, Covariates Included, YES) 
	
* DV: terms to first completion
* IV: cumulative number of 7-week courses taken through term 18 (0, 1, or 2+) 
* --> because we only pulled 18 terms of completions
reg dv_terms_first_completion i.$t1_dv, robust
test 1.$t1_dv = 2.$t1_dv
outreg2 using "$output_file_name", append dec(3) label ///
	keep(1.$t1_dv 2.$t1_dv) alpha(0.001, 0.01, 0.05) 
areg dv_terms_first_completion i.$t1_dv $covariates, a(fe_cohort_inst) robust
test 1.$t1_dv = 2.$t1_dv
outreg2 using "$output_file_name", append dec(3) label ///
	keep(1.$t1_dv 2.$t1_dv) alpha(0.001, 0.01, 0.05) ///
	addtext(Cohort by Institution FE, YES, Covariates Included, YES) 
	
* DV: number of completions
* IV: cumulative number of 7-week courses taken through term 18 (0, 1, or 2+) 
* --> because we only pulled 18 terms of completions
reg dv_number_completions i.$t1_dv, robust
test 1.$t1_dv = 2.$t1_dv
outreg2 using "$output_file_name", append dec(3) label ///
	keep(1.$t1_dv 2.$t1_dv) alpha(0.001, 0.01, 0.05) 
areg dv_number_completions i.$t1_dv $covariates, a(fe_cohort_inst) robust
test 1.$t1_dv = 2.$t1_dv
outreg2 using "$output_file_name", append dec(3) label ///
	keep(1.$t1_dv 2.$t1_dv) alpha(0.001, 0.01, 0.05) ///
	addtext(Cohort by Institution FE, YES, Covariates Included, YES) 

log close	

}

*****************************************************************************
** ROBUSTNESS - DISAGGREGATING BY FYE/FYS COURSE STATUS
*****************************************************************************

if `apptab4_fyedisagg' == 1 { 

**********************************************************
* The following code was used to generate Appendix Table 4
**********************************************************

cd "${output}"
log using "FYE_Students.smcl", replace

* Load in the data
******************

* Start with the analytic dataset
use "${dta}analytic_dataset.dta", clear

********************************************************************************
* Estimate effects by course type taken (only 15, only FYE in 7, other 7)
********************************************************************************

* Merge with the FYE/FYS course list
merge m:1 course_title_id course_fe using "${dta}fye_fys_courses.dta"

* Keep only the FYE observations
keep if _merge == 3

* Keep only the 7-week FYE observations
keep if course_acc == 1

* Check for duplicates
duplicates tag student_id, gen(dupes)
sort student_id term_code
br student_id term_code course_fe final_grade_clean if dupes != 0

* Much (all?) of this seems to be students who repeated the course. We only need
* one record of them having taken the course in a 7-week format, so remove the
* duplicates.

gsort student_id -term_code // Privileging the later retake grade
	* Note: We may also consider the first (typically lower) grade
duplicates drop student_id, force
keep student_id

* Save a tempfile to merge with the student-level dataset
tempfile fye_7wks
save `fye_7wks'

* Start with the student-level dataset
use "${dta}cohort_analytic_dataset.dta", clear

* Merge with the list of students who took FYE in 7 weeks
merge 1:1 student_id using `fye_7wks', keep(master match)

* Generate variables that capture (only 15, only FYE in 7, other 7) in each term
foreach term in "t1" "t2" "t4" "t5" "t7" "t8" "t10" "t11" "t13" "t14" "t16" ///
	"t17" {
g `term'_iv_by_course_type = 0 if `term'_7wk_courses_cumu == 0
replace `term'_iv_by_course_type = 2 if `term'_7wk_courses_cumu > 0 & ///
	`term'_7wk_courses_cumu != .
replace `term'_iv_by_course_type = 1 if _merge == 3 & ///
	`term'_7wk_courses_cumu == 1
ta `term'_7wk_courses_cumu `term'_iv_by_course_type, m
}

* Generate the variables for summer and replace with the spring values since we
* don't include summer in our course enrollment data
g t3_iv_by_course_type = t2_iv_by_course_type
g t6_iv_by_course_type = t5_iv_by_course_type
g t9_iv_by_course_type = t8_iv_by_course_type
g t12_iv_by_course_type = t11_iv_by_course_type
g t15_iv_by_course_type = t14_iv_by_course_type
g t18_iv_by_course_type = t17_iv_by_course_type

* Label the values so we know what they mean
label define iv_by_course_type 0 "Only 15-week courses" ///
	1 "Only took FYE in 7 weeks" 2 "Took non-FYE in 7 weeks"
label values *_iv_by_course_type iv_by_course_type

********************************************************************************
* Selection
********************************************************************************

* Create a global macro with all the covariates
gl covariates pell_recipient female asian black hisp multi ///
	race_oth_under1000 white full_time_in_first_term ///
	ls_number ls_math_required ls_reading_required ls_writing_required ///
	hs_gpa_models hs_gpa_models_missing 

* Naive OLS to get the control mean -- Constant (_cons) in this regression	
reg age_25plus i.t12_iv_by_course_type, robust 
test 1.t12_iv_by_course_type = 2.t12_iv_by_course_type
outreg2 using "selection_studentlevel_discrete_iv_FYE_controlmean.xls", ///
	excel replace ///
	dec(3) alpha(0.001, 0.01, 0.05)
	
foreach control of varlist $covariates {

* Naive OLS to get the control mean -- Constant (_cons) in this regression	
reg `control' i.t12_iv_by_course_type, robust 
test 1.t12_iv_by_course_type = 2.t12_iv_by_course_type
outreg2 using "selection_studentlevel_discrete_iv_FYE_controlmean.xls", ///
	excel append ///
	dec(3) alpha(0.001, 0.01, 0.05)
	
}

* DV: student is age 25+ (0/1)
areg age_25plus i.t12_iv_by_course_type, a(fe_cohort_inst) robust
test 1.t12_iv_by_course_type = 2.t12_iv_by_course_type
outreg2 using "selection_studentlevel_discrete_iv_FYE.xls", replace ///
	keep(1.t12_iv_by_course_type 2.t12_iv_by_course_type) ///
	addtext(Cohort by Institution FE, YES) dec(3) alpha(0.001, 0.01, 0.05) 

foreach control of varlist $covariates {
	
* DV: looping through student-level covariates
areg `control' i.t12_iv_by_course_type, a(fe_cohort_inst) robust
test 1.t12_iv_by_course_type = 2.t12_iv_by_course_type
outreg2 using "selection_studentlevel_discrete_iv_FYE.xls", append ///
	keep(1.t12_iv_by_course_type 2.t12_iv_by_course_type) ///
	addtext(Cohort by Institution FE, YES) dec(3) alpha(0.001, 0.01, 0.05) 

}

********************************************************************************
* Outcomes estimates for all schools
********************************************************************************

* Create a global macro with all the covariates
gl covariates age_25plus pell_recipient female asian black hisp multi ///
	race_oth_under1000 full_time_in_first_term ///
	ls_math_required ls_reading_required ls_writing_required ///
	hs_gpa_models hs_gpa_models_missing twodig_cip_major_unknown ///
	i.twodig_cip_major
	
* Set globals for models
gl t1_dv t1_iv_by_course_type
gl t3_dv t1_iv_by_course_type
gl t6_dv t1_iv_by_course_type
gl t9_dv t1_iv_by_course_type
gl t18_dv t1_iv_by_course_type
gl output_file_name CohortBasedOutcomes_FYE.xls

* Keep only students with longer-term outcomes
keep if t1_term_code < 202280

* Change the discrete IV to 0, 1, or 2+ 7-week courses
foreach var of varlist *7wk_courses_cumu_iv {
	replace `var' = 2 if `var' > 2 & `var' != .
}
label define lab_7wk_courses_cumu_iv 0 "0 7-Week Courses" 1 ///
	"1 7-Week Course" 2 "2+ 7-Week Courses"
label values *_7wk_courses_cumu_iv lab_7wk_courses_cumu_iv

tab t1_7wk_courses_cumu_iv t1_iv_by_course_type 

*DV: term GPA, term 1
*IV: in term 1, 0=only 15; 1=only FYE in 7; 2=other 7 in term 1
reg dv_t1_term_gpa i.$t1_dv, robust
test 1.$t1_dv = 2.$t1_dv
outreg2 using "$output_file_name", replace dec(3) ///
	keep(1.$t1_dv 2.$t1_dv) alpha(0.001, 0.01, 0.05) label
areg dv_t1_term_gpa i.$t1_dv $covariates, a(fe_cohort_inst) robust
test 1.$t1_dv = 2.$t1_dv
outreg2 using "$output_file_name", append dec(3) ///
	keep(1.$t1_dv 2.$t1_dv) alpha(0.001, 0.01, 0.05) ///
	addtext(Cohort by Institution FE, YES, Covariates Included, YES) 

*DV: cumulative GPA, term 1 (home + transfer hours)
*IV: in term 1, 0=only 15; 1=only FYE in 7; 2=other 7 in term 1
reg dv_t1_cumu_home_tran_gpa i.$t1_dv, robust
test 1.$t1_dv = 2.$t1_dv
outreg2 using "$output_file_name", append dec(3) ///
	keep(1.$t1_dv 2.$t1_dv) alpha(0.001, 0.01, 0.05) 
areg dv_t1_cumu_home_tran_gpa i.$t1_dv $covariates, a(fe_cohort_inst) robust
test 1.$t1_dv = 2.$t1_dv
outreg2 using "$output_file_name", append dec(3) ///
	keep(1.$t1_dv 2.$t1_dv) alpha(0.001, 0.01, 0.05) ///
	addtext(Cohort by Institution FE, YES, Covariates Included, YES)  

*DV: percent of attempted hours earned, term 1
*IV: in term 1, 0=only 15; 1=only FYE in 7; 2=other 7 in term 1
reg dv_t1_pct_earned i.$t1_dv, robust
test 1.$t1_dv = 2.$t1_dv
outreg2 using "$output_file_name", append dec(3) ///
	keep(1.$t1_dv 2.$t1_dv) alpha(0.001, 0.01, 0.05) 
areg dv_t1_pct_earned i.$t1_dv $covariates, a(fe_cohort_inst) robust
test 1.$t1_dv = 2.$t1_dv
outreg2 using "$output_file_name", append dec(3) ///
	keep(1.$t1_dv 2.$t1_dv) alpha(0.001, 0.01, 0.05) ///
	addtext(Cohort by Institution FE, YES, Covariates Included, YES) 
	
*DV: persistence to term 2 (first spring)
*IV: in term 1, 0=only 15; 1=only FYE in 7; 2=other 7 in term 1
reg dv_persist_t2 i.$t1_dv, robust
test 1.$t1_dv = 2.$t1_dv
outreg2 using "$output_file_name", append dec(3) ///
	keep(1.$t1_dv 2.$t1_dv) alpha(0.001, 0.01, 0.05) 
areg dv_persist_t2 i.$t1_dv $covariates, a(fe_cohort_inst) robust
test 1.$t1_dv = 2.$t1_dv
outreg2 using "$output_file_name", append dec(3) ///
	keep(1.$t1_dv 2.$t1_dv) alpha(0.001, 0.01, 0.05) ///
	addtext(Cohort by Institution FE, YES, Covariates Included, YES) 
	
*DV: cumulative GPA, year 1 (home + transfer hours)
*IV: through term 3, 0=only 15; 1=only FYE in 7; 2=other 7 in term 1
reg dv_y1_cumu_home_tran_gpa i.$t3_dv, robust
test 1.$t3_dv = 2.$t3_dv
outreg2 using "$output_file_name", append dec(3) ///
	keep(1.$t3_dv 2.$t3_dv) alpha(0.001, 0.01, 0.05) 
areg dv_y1_cumu_home_tran_gpa i.$t3_dv $covariates, a(fe_cohort_inst) robust
test 1.$t3_dv = 2.$t3_dv
outreg2 using "$output_file_name", append dec(3) ///
	keep(1.$t3_dv 2.$t3_dv) alpha(0.001, 0.01, 0.05) ///
	addtext(Cohort by Institution FE, YES, Covariates Included, YES) 

*DV: percent of attempted hours earned, year 1
*IV: through term 3, 0=only 15; 1=only FYE in 7; 2=other 7 in term 1
reg dv_y1_pct_earned i.$t3_dv, robust
test 1.$t3_dv = 2.$t3_dv
outreg2 using "$output_file_name", append dec(3) ///
	keep(1.$t3_dv 2.$t3_dv) alpha(0.001, 0.01, 0.05) 
areg dv_y1_pct_earned i.$t3_dv $covariates, a(fe_cohort_inst) robust
test 1.$t3_dv = 2.$t3_dv
outreg2 using "$output_file_name", append dec(3) ///
	keep(1.$t3_dv 2.$t3_dv) alpha(0.001, 0.01, 0.05) ///
	addtext(Cohort by Institution FE, YES, Covariates Included, YES) 
	
*DV: persistence to term 4 (second fall)
*IV: through term 3, 0=only 15; 1=only FYE in 7; 2=other 7 in term 1
reg dv_persist_t4 i.$t3_dv, robust
test 1.$t3_dv = 2.$t3_dv
outreg2 using "$output_file_name", append dec(3) ///
	keep(1.$t3_dv 2.$t3_dv) alpha(0.001, 0.01, 0.05) 
areg dv_persist_t4 i.$t3_dv $covariates, a(fe_cohort_inst) robust
test 1.$t3_dv = 2.$t3_dv
outreg2 using "$output_file_name", append dec(3) ///
	keep(1.$t3_dv 2.$t3_dv) alpha(0.001, 0.01, 0.05) ///
	addtext(Cohort by Institution FE, YES, Covariates Included, YES) 

*DV: persistence to year 2 (any term in second year)
*IV: through term 3, 0=only 15; 1=only FYE in 7; 2=other 7 in term 1
reg dv_persist_y2 i.$t3_dv, robust
test 1.$t3_dv = 2.$t3_dv
outreg2 using "$output_file_name", append dec(3) ///
	keep(1.$t3_dv 2.$t3_dv) alpha(0.001, 0.01, 0.05) 
areg dv_persist_y2 i.$t3_dv $covariates, a(fe_cohort_inst) robust
test 1.$t3_dv = 2.$t3_dv
outreg2 using "$output_file_name", append dec(3) ///
	keep(1.$t3_dv 2.$t3_dv) alpha(0.001, 0.01, 0.05) ///
	addtext(Cohort by Institution FE, YES, Covariates Included, YES) 
	
*DV: graduation within 2 years
*IV: through term 6, 0=only 15; 1=only FYE in 7; 2=other 7 in term 1
reg dv_grad_y2 i.$t6_dv, robust
test 1.$t6_dv = 2.$t6_dv
outreg2 using "$output_file_name", append dec(3) ///
	keep(1.$t6_dv 2.$t6_dv) alpha(0.001, 0.01, 0.05) 
areg dv_grad_y2 i.$t6_dv $covariates, a(fe_cohort_inst) robust
test 1.$t6_dv = 2.$t6_dv
outreg2 using "$output_file_name", append dec(3) ///
	keep(1.$t6_dv 2.$t6_dv) alpha(0.001, 0.01, 0.05) ///
	addtext(Cohort by Institution FE, YES, Covariates Included, YES) 
	
*DV: persistence to term 7 (third fall)
*IV: through term 6, 0=only 15; 1=only FYE in 7; 2=other 7 in term 1
reg dv_persist_t7 i.$t6_dv, robust
test 1.$t6_dv = 2.$t6_dv
outreg2 using "$output_file_name", append dec(3) ///
	keep(1.$t6_dv 2.$t6_dv) alpha(0.001, 0.01, 0.05)  
areg dv_persist_t7 i.$t6_dv $covariates, a(fe_cohort_inst) robust
test 1.$t6_dv = 2.$t6_dv
outreg2 using "$output_file_name", append dec(3) ///
	keep(1.$t6_dv 2.$t6_dv) alpha(0.001, 0.01, 0.05) ///
	addtext(Cohort by Institution FE, YES, Covariates Included, YES) 
	
*DV: persistence to year 3 (any term in third year)
*IV: through term 6, 0=only 15; 1=only FYE in 7; 2=other 7 in term 1
reg dv_persist_y3 i.$t6_dv, robust
test 1.$t6_dv = 2.$t6_dv
outreg2 using "$output_file_name", append dec(3) ///
	keep(1.$t6_dv 2.$t6_dv) alpha(0.001, 0.01, 0.05) 
areg dv_persist_y3 i.$t6_dv $covariates, a(fe_cohort_inst) robust
test 1.$t6_dv = 2.$t6_dv
outreg2 using "$output_file_name", append dec(3) ///
	keep(1.$t6_dv 2.$t6_dv) alpha(0.001, 0.01, 0.05) ///
	addtext(Cohort by Institution FE, YES, Covariates Included, YES) 

*DV: graduation within 3 years
*IV: through term 9, 0=only 15; 1=only FYE in 7; 2=other 7 in term 1
reg dv_grad_y3 i.$t9_dv, robust
test 1.$t9_dv = 2.$t9_dv
outreg2 using "$output_file_name", append dec(3) ///
	keep(1.$t9_dv 2.$t9_dv) alpha(0.001, 0.01, 0.05)
areg dv_grad_y3 i.$t9_dv $covariates, a(fe_cohort_inst) robust
test 1.$t9_dv = 2.$t9_dv
outreg2 using "$output_file_name", append dec(3) ///
	keep(1.$t9_dv 2.$t9_dv) alpha(0.001, 0.01, 0.05) ///
	addtext(Cohort by Institution FE, YES, Covariates Included, YES) 
	
*DV: terms to first completion
*IV: through term 18, 0=only 15; 1=only FYE in 7; 2=other 7 in term 1
reg dv_terms_first_completion i.$t18_dv, robust
test 1.$t18_dv = 2.$t18_dv
outreg2 using "$output_file_name", append dec(3) ///
	keep(1.$t18_dv 2.$t18_dv) alpha(0.001, 0.01, 0.05) 
areg dv_terms_first_completion i.$t18_dv $covariates, a(fe_cohort_inst) robust
test 1.$t18_dv = 2.$t18_dv
outreg2 using "$output_file_name", append dec(3) ///
	keep(1.$t18_dv 2.$t18_dv) alpha(0.001, 0.01, 0.05) ///
	addtext(Cohort by Institution FE, YES, Covariates Included, YES) 
	
*DV: number of completions
*IV: through term 18, 0=only 15; 1=only FYE in 7; 2=other 7 in term 1
reg dv_number_completions i.$t18_dv, robust
test 1.$t18_dv = 2.$t18_dv
outreg2 using "$output_file_name", append dec(3) ///
	keep(1.$t18_dv 2.$t18_dv) alpha(0.001, 0.01, 0.05) 
areg dv_number_completions i.$t18_dv $covariates, a(fe_cohort_inst) robust
test 1.$t18_dv = 2.$t18_dv
outreg2 using "$output_file_name", append dec(3) ///
	keep(1.$t18_dv 2.$t18_dv) alpha(0.001, 0.01, 0.05) ///
	addtext(Cohort by Institution FE, YES, Covariates Included, YES) 

********************************************************************************
* Disaggregating Between 1 Course (FYE), 1 Course (Non-FYE), 2+ Courses
********************************************************************************

* Generate Discrete Accelerated Coursetaking Indicator
g t1_iv_by_course_type_disag = t1_iv_by_course_type
replace t1_iv_by_course_type_disag = 3 if t1_7wk_courses_cumu_iv == 2

* Label the values so we know what they mean
label define iv_by_course_type_disag 0 "Only 15-week courses" ///
	1 "Only took FYE in 7 weeks" 2 "Only took non-FYE in 7 weeks" ///
	3 "Took 2+ Courses in 7 Weeks"
label values t1_iv_by_course_type_disag iv_by_course_type_disag

* Set globals for models
gl t1_dv t1_iv_by_course_type_disag
gl t3_dv t1_iv_by_course_type_disag
gl t6_dv t1_iv_by_course_type_disag
gl t9_dv t1_iv_by_course_type_disag
gl t18_dv t1_iv_by_course_type_disag
gl output_file_name CohortBasedOutcomes_FYE_Disag.xls

* Identify SDs for continuous control vars 
bysort t1_iv_by_course_type_disag: su dv_t1_term_gpa dv_y1_cumu_home_tran_gpa

* DV: term GPA, term 1
* IV: in term 1, 0=only 15; 1=only FYE in 7; 2=other 7 in term 1
reg dv_t1_term_gpa i.$t1_dv, robust
test 1.$t1_dv = 2.$t1_dv
outreg2 using "$output_file_name", replace dec(3) ///
	keep(1.$t1_dv 2.$t1_dv 3.$t1_dv) alpha(0.001, 0.01, 0.05) label
areg dv_t1_term_gpa i.$t1_dv $covariates, a(fe_cohort_inst) robust
test 1.$t1_dv = 2.$t1_dv
outreg2 using "$output_file_name", append dec(3) ///
	keep(1.$t1_dv 2.$t1_dv 3.$t1_dv) alpha(0.001, 0.01, 0.05) ///
	addtext(Cohort by Institution FE, YES, Covariates Included, YES) 

* DV: cumulative GPA, term 1 (home + transfer hours)
* IV: in term 1, 0=only 15; 1=only FYE in 7; 2=other 7 in term 1
reg dv_t1_cumu_home_tran_gpa i.$t1_dv, robust
test 1.$t1_dv = 2.$t1_dv
outreg2 using "$output_file_name", append dec(3) ///
	keep(1.$t1_dv 2.$t1_dv 3.$t1_dv) alpha(0.001, 0.01, 0.05) label
areg dv_t1_cumu_home_tran_gpa i.$t1_dv $covariates, a(fe_cohort_inst) robust
test 1.$t1_dv = 2.$t1_dv
outreg2 using "$output_file_name", append dec(3) ///
	keep(1.$t1_dv 2.$t1_dv 3.$t1_dv) alpha(0.001, 0.01, 0.05) ///
	addtext(Cohort by Institution FE, YES, Covariates Included, YES)  

* DV: percent of attempted hours earned, term 1
* IV: in term 1, 0=only 15; 1=only FYE in 7; 2=other 7 in term 1
reg dv_t1_pct_earned i.$t1_dv, robust
test 1.$t1_dv = 2.$t1_dv
outreg2 using "$output_file_name", append dec(3) ///
	keep(1.$t1_dv 2.$t1_dv 3.$t1_dv) alpha(0.001, 0.01, 0.05) label
areg dv_t1_pct_earned i.$t1_dv $covariates, a(fe_cohort_inst) robust
test 1.$t1_dv = 2.$t1_dv
outreg2 using "$output_file_name", append dec(3) ///
	keep(1.$t1_dv 2.$t1_dv 3.$t1_dv) alpha(0.001, 0.01, 0.05) ///
	addtext(Cohort by Institution FE, YES, Covariates Included, YES) 
	
* DV: persistence to term 2 (first spring)
* IV: in term 1, 0=only 15; 1=only FYE in 7; 2=other 7 in term 1
reg dv_persist_t2 i.$t1_dv, robust
test 1.$t1_dv = 2.$t1_dv
outreg2 using "$output_file_name", append dec(3) ///
	keep(1.$t1_dv 2.$t1_dv 3.$t1_dv) alpha(0.001, 0.01, 0.05) label
areg dv_persist_t2 i.$t1_dv $covariates, a(fe_cohort_inst) robust
test 1.$t1_dv = 2.$t1_dv
outreg2 using "$output_file_name", append dec(3) ///
	keep(1.$t1_dv 2.$t1_dv 3.$t1_dv) alpha(0.001, 0.01, 0.05) ///
	addtext(Cohort by Institution FE, YES, Covariates Included, YES) 
	
* DV: cumulative GPA, year 1 (home + transfer hours)
* IV: through term 3, 0=only 15; 1=only FYE in 7; 2=other 7 in term 1
reg dv_y1_cumu_home_tran_gpa i.$t3_dv, robust
test 1.$t3_dv = 2.$t3_dv
outreg2 using "$output_file_name", append dec(3) ///
	keep(1.$t3_dv 2.$t3_dv 3.$t3_dv) alpha(0.001, 0.01, 0.05) label
areg dv_y1_cumu_home_tran_gpa i.$t3_dv $covariates, a(fe_cohort_inst) robust
test 1.$t3_dv = 2.$t3_dv
outreg2 using "$output_file_name", append dec(3) ///
	keep(1.$t3_dv 2.$t3_dv 3.$t3_dv) alpha(0.001, 0.01, 0.05) ///
	addtext(Cohort by Institution FE, YES, Covariates Included, YES) 

* DV: percent of attempted hours earned, year 1
* IV: through term 3, 0=only 15; 1=only FYE in 7; 2=other 7 in term 1
reg dv_y1_pct_earned i.$t3_dv, robust
test 1.$t3_dv = 2.$t3_dv
outreg2 using "$output_file_name", append dec(3) ///
	keep(1.$t3_dv 2.$t3_dv 3.$t3_dv) alpha(0.001, 0.01, 0.05) label
areg dv_y1_pct_earned i.$t3_dv $covariates, a(fe_cohort_inst) robust
test 1.$t3_dv = 2.$t3_dv
outreg2 using "$output_file_name", append dec(3) ///
	keep(1.$t3_dv 2.$t3_dv 3.$t3_dv) alpha(0.001, 0.01, 0.05) ///
	addtext(Cohort by Institution FE, YES, Covariates Included, YES) 
	
* DV: persistence to term 4 (second fall)
* IV: through term 3, 0=only 15; 1=only FYE in 7; 2=other 7 in term 1
reg dv_persist_t4 i.$t3_dv, robust
test 1.$t3_dv = 2.$t3_dv
outreg2 using "$output_file_name", append dec(3) ///
	keep(1.$t3_dv 2.$t3_dv 3.$t3_dv) alpha(0.001, 0.01, 0.05) label
areg dv_persist_t4 i.$t3_dv $covariates, a(fe_cohort_inst) robust
test 1.$t3_dv = 2.$t3_dv
outreg2 using "$output_file_name", append dec(3) ///
	keep(1.$t3_dv 2.$t3_dv 3.$t3_dv) alpha(0.001, 0.01, 0.05) ///
	addtext(Cohort by Institution FE, YES, Covariates Included, YES) 

* DV: persistence to year 2 (any term in second year)
* IV: through term 3, 0=only 15; 1=only FYE in 7; 2=other 7 in term 1
reg dv_persist_y2 i.$t3_dv, robust
test 1.$t3_dv = 2.$t3_dv
outreg2 using "$output_file_name", append dec(3) ///
	keep(1.$t3_dv 2.$t3_dv 3.$t3_dv) alpha(0.001, 0.01, 0.05) label
areg dv_persist_y2 i.$t3_dv $covariates, a(fe_cohort_inst) robust
test 1.$t3_dv = 2.$t3_dv
outreg2 using "$output_file_name", append dec(3) ///
	keep(1.$t3_dv 2.$t3_dv 3.$t3_dv) alpha(0.001, 0.01, 0.05) ///
	addtext(Cohort by Institution FE, YES, Covariates Included, YES) 
	
* DV: graduation within 2 years
* IV: through term 6, 0=only 15; 1=only FYE in 7; 2=other 7 in term 1
reg dv_grad_y2 i.$t6_dv, robust
test 1.$t6_dv = 2.$t6_dv
outreg2 using "$output_file_name", append dec(3) ///
	keep(1.$t6_dv 2.$t6_dv 3.$t6_dv) alpha(0.001, 0.01, 0.05) label
areg dv_grad_y2 i.$t6_dv $covariates, a(fe_cohort_inst) robust
test 1.$t6_dv = 2.$t6_dv
outreg2 using "$output_file_name", append dec(3) ///
	keep(1.$t6_dv 2.$t6_dv 3.$t6_dv) alpha(0.001, 0.01, 0.05) ///
	addtext(Cohort by Institution FE, YES, Covariates Included, YES) 
	
* DV: persistence to term 7 (third fall)
* IV: through term 6, 0=only 15; 1=only FYE in 7; 2=other 7 in term 1
reg dv_persist_t7 i.$t6_dv, robust
test 1.$t6_dv = 2.$t6_dv
outreg2 using "$output_file_name", append dec(3) ///
	keep(1.$t6_dv 2.$t6_dv 3.$t6_dv) alpha(0.001, 0.01, 0.05) label
areg dv_persist_t7 i.$t6_dv $covariates, a(fe_cohort_inst) robust
test 1.$t6_dv = 2.$t6_dv
outreg2 using "$output_file_name", append dec(3) ///
	keep(1.$t6_dv 2.$t6_dv 3.$t6_dv) alpha(0.001, 0.01, 0.05) ///
	addtext(Cohort by Institution FE, YES, Covariates Included, YES) 
	
* DV: persistence to year 3 (any term in third year)
* IV: through term 6, 0=only 15; 1=only FYE in 7; 2=other 7 in term 1
reg dv_persist_y3 i.$t6_dv, robust
test 1.$t6_dv = 2.$t6_dv
outreg2 using "$output_file_name", append dec(3) ///
	keep(1.$t6_dv 2.$t6_dv 3.$t6_dv) alpha(0.001, 0.01, 0.05) label
areg dv_persist_y3 i.$t6_dv $covariates, a(fe_cohort_inst) robust
test 1.$t6_dv = 2.$t6_dv
outreg2 using "$output_file_name", append dec(3) ///
	keep(1.$t6_dv 2.$t6_dv 3.$t6_dv) alpha(0.001, 0.01, 0.05) ///
	addtext(Cohort by Institution FE, YES, Covariates Included, YES) 

* DV: graduation within 3 years
* IV: through term 9, 0=only 15; 1=only FYE in 7; 2=other 7 in term 1
reg dv_grad_y3 i.$t9_dv, robust
test 1.$t9_dv = 2.$t9_dv
outreg2 using "$output_file_name", append dec(3) ///
	keep(1.$t9_dv 2.$t9_dv 3.$t9_dv) alpha(0.001, 0.01, 0.05) label
areg dv_grad_y3 i.$t9_dv $covariates, a(fe_cohort_inst) robust
test 1.$t9_dv = 2.$t9_dv
outreg2 using "$output_file_name", append dec(3) ///
	keep(1.$t9_dv 2.$t9_dv 3.$t9_dv) alpha(0.001, 0.01, 0.05) ///
	addtext(Cohort by Institution FE, YES, Covariates Included, YES) 
	
* DV: terms to first completion
* IV: through term 18, 0=only 15; 1=only FYE in 7; 2=other 7 in term 1
reg dv_terms_first_completion i.$t18_dv, robust
test 1.$t18_dv = 2.$t18_dv
outreg2 using "$output_file_name", append dec(3) ///
	keep(1.$t18_dv 2.$t18_dv 3.$t18_dv) alpha(0.001, 0.01, 0.05) label
areg dv_terms_first_completion i.$t18_dv $covariates, a(fe_cohort_inst) robust
test 1.$t18_dv = 2.$t18_dv
outreg2 using "$output_file_name", append dec(3) ///
	keep(1.$t18_dv 2.$t18_dv 3.$t18_dv) alpha(0.001, 0.01, 0.05) ///
	addtext(Cohort by Institution FE, YES, Covariates Included, YES) 
	
* DV: number of completions
* IV: through term 18, 0=only 15; 1=only FYE in 7; 2=other 7 in term 1
reg dv_number_completions i.$t18_dv, robust
test 1.$t18_dv = 2.$t18_dv
outreg2 using "$output_file_name", append dec(3) ///
	keep(1.$t18_dv 2.$t18_dv 3.$t18_dv) alpha(0.001, 0.01, 0.05) label
areg dv_number_completions i.$t18_dv $covariates, a(fe_cohort_inst) robust
test 1.$t18_dv = 2.$t18_dv
outreg2 using "$output_file_name", append dec(3) ///
	keep(1.$t18_dv 2.$t18_dv 3.$t18_dv) alpha(0.001, 0.01, 0.05) ///
	addtext(Cohort by Institution FE, YES, Covariates Included, YES) 

log close 

}

* Fin
